Code Smell: Blowers

Lecture



Blowers represent code, methods, and classes that have swelled to such large dimensions that it was impossible to work effectively with them. All these smells often do not appear immediately, but increase in the process of program evolution (especially when no one tries to deal with them).

Long method

The method contains too many lines of code. Method length over ten lines should start to bother you.

Big class

The class contains many fields / methods / lines of code.

Obsession with elementary types

  • Using elementary types instead of small objects for small tasks (for example, currency, ranges, special strings for telephone numbers, etc.)
  • Using constants to encode some information (for example, the constant USER_ADMIN_ROLE = 1 to indicate users with the role of administrator).
  • Use string constants as field names in arrays.

Long list of parameters

The number of method parameters is more than three or four.

Data groups

Sometimes in different parts of the code there are the same groups of variables (for example, the parameters for connecting to the database). Such groups should be turned into independent classes.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Refactoring theory

Terms: Refactoring theory