Why shouldn’t you use ‘Comments’? ( 3 points )
When can we use ‘Comments’? ( 3 points )
Why shouldn’t we use ‘Long methods’? ( 2 )
Why shouldn’t we use ‘Long class/modules? ( 2 )
Why shouldn’t we use ‘Long parameter list’?
What is ‘embedded in name’ smell?
When you add unnecessary value to the name:
- add_course(course)
When you add type to the name
- animal_string
What is ‘uncommunicative name’ smell?
When you use:
- One or two-character names
- Misleading names
- abbreviations
What is ‘Inconsistent name’ smell?
One name is used in one place, and a different name is used for the same thing somewhere else. For example, in a single application you might see add, store, put, and place for the same basic method.
Sample: ‘Destroy, delete, remove for the same method;’
What is ‘Dead code’ smell?
A variable, parameter, code fragment, method, module, or class is not used anywhere (perhaps other than in tests).
Why should we remove ‘Dead code’?
What is ‘Speculative generality’ code smell?
The same as You ain’t gonna need it
This code smell describes a situation where people develop a class with all sorts of hooks and special cases just so it will handle things that might be required in the future but not at this stage
What is ‘Greedy Method’ code smell?
When code do more than one job or have several levels of abstraction. ( More than one responsibility )
What is ‘Procedural code’ smell?
Don’t use procedural code ( like loop, while with temp variables) if you can use each
What is ‘Dynamic code creation’ code smell?
Don’t use eval
What is Derived Value code smell?
When you have code which was defined from scratch instead of getting from another value:
NAME = ‘Nic’
SURNAME = ‘Mil’
FULL_NAME = ‘Nic Mil’
But we can leave this code smell for the tests.
What is Repeated Value code smell?
When you have a string more than one time in the code.
You need to move this string to the constant.
What is Duplication code code smell?
Two fragments of code look nearly identical.
What is Alternative Modules with Different Interfaces code smell?
Two classes or modules seem to be doing the same thing but are using different method names.
What is ‘Nil check` smell?
Try to avoid using nil check
What is Special case code smell?
What is Complicated Boolean Expression code smell?
Code has complex conditions involving and, or, and not.
Example:
- if !a
- !(a && b)
What is Control Coupling code smell?
• A method or block checks the value of a parameter in order to decide which execution path to take.
• A method’s name includes a word such as “or.”
What is Simulated Polymorphism code smell?
• Code uses a case statement (especially on a type field).
• Code has several if statements in a row (especially if they’re comparing against the same value).
What is ‘Primitive Obsession’ code smell?
(Одержимость примитивными типами)
When you use primitive types as a string on number instead of creating new Class. ( For example Money, Data.. constant that includes Number instead of meaning )