Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (47 sloc) 2.31 KB
Root.Smell Parent Index
Sibling aspects Formatting Metadata Redundancy Security Spelling

Smell

Symptom in a piece of code that possibly indicates a deeper problem.

Smells are certain structures in a code that indicate violation of fundamental design principles. They are usually not bugs; they are not technically incorrect and do not currently prevent the program from functioning.

Subaspects

Example

=begin
Example of Ruby code with data clumps and methods with too many
parameters.
=end
class Dummy
    def x(y1, y2, y3, y4, y5, y6, y7, y8, a); end
    def y(y1, y2, y3, y4, y5, y6, y7, y8); end
    def z(y1, y2, y3, y4, y5, y6, y7, y8); end
end

Importance

Even though they are not necessarily bugs, code smells increase the risk of bugs or failure in the future and may slow down development.

How to fix this

There are several refactoring techniques that can be used to deal with code smells including:

  • Composing methods
  • Moving features between objects
  • Organizing data
  • Simplifying conditional expressions
  • Simplifying method calls
  • Dealing with generalisation

See <https://sourcemaking.com/refactoring/refactorings> for more information.