Skip to content

Code smells list

Morteza Zakeri edited this page Mar 16, 2021 · 1 revision

Code smells list

The following code smells are detected by CodART.

Table 2. Code smells

Code smell Descriptions and other names
God class The class defines many data members (fields) and methods and exhibits low cohesion. The god class smell occurs when a huge class surrounded by many data classes acts as a controller (i.e., takes most of the decisions and monopolizes the software's functionality). Other names: Blob, large class, brain class.
Long method This smell occurs when a method is too long to understand and most presumably perform more than one responsibility. Other names: God method, brain method, large method.
Feature envy This smell occurs when a method seems more interested in a class other than the one it actually is in.
Data class This smell occurs when a class contains only fields and possibly getters/setters without any behavior (methods).
Shotgun surgery This smell characterizes the situation when one kind of change leads to many changes to multiple different classes. When the changes are all over the place, they are hard to find, and it is easy to miss a necessary change.
Refused bequest This smell occurs when a subclass rejects some of the methods or properties offered by its superclass.
Functional decomposition This smell occurs when the experienced developers coming from procedural languages background write highly procedural and non-object-oriented code in an object-oriented language.
Long parameter list This smell occurs when a method accepts a long list of parameters. Such lists are hard to understand and difficult to use.
Promiscuous package A package can be considered promiscuous if it contains classes implementing too many features, making it too hard to understand and maintain. As for god class and long method, this smell arises when the package has low cohesion since it manages different responsibilities.
Misplaced class A Misplaced Class smell suggests a class that is in a package that contains other classes not related to it.
Switch statement This smell occurs when switch statements that switch on type codes are spread across the software system instead of exploiting polymorphism.
Spaghetti code This smell refers to an unmaintainable, incomprehensible code without any structure. The smell does not exploit and prevents the use of object-orientation mechanisms and concepts.
Divergent change Divergent change occurs when one class is commonly changed in different ways for different reasons. Other names: Multifaceted abstraction
Deficient encapsulation This smell occurs when the declared accessibility of one or more members of abstraction is more permissive than actually required.
Swiss army knife This smell arises when the designer attempts to provide all possible uses of the class and ends up in an excessively complex class interface.
Lazy class Unnecessary abstraction
Cyclically-dependent modularization This smell arises when two or more abstractions depend on each other directly or indirectly.
Primitive obsession This smell occurs when primitive data types are used where an abstraction encapsulating the primitives could serve better.
Speculative generality This smell occurs where abstraction is created based on speculated requirements. It is often unnecessary that makes things difficult to understand and maintain.
Message chains A message chain occurs when a client requests another object, that object requests yet another one, and so on. These chains mean that the client is dependent on navigation along with the class structure. Any changes in these relationships require modifying the client.
Total 20

Welcome to CodART Wiki. CoaART is an automated source code refactoring toolkit for large programs written in Java.

Clone this wiki locally