Research Article

Exploring the Eradication of Code Smells: An Empirical and Theoretical Perspective

Table 1

Code smells and their description.

SmellDescription

(1) Alternative classes with different interfacesTwo classes appear different on the outside, but are similar on the inside
(2) CommentsComments should describe why the code is there not what it does
(3) Data classClasses should not contain just data, they should contain methods as well
(4) Data clumpsData that belong together should be amalgamated rather than remain separated
(5) Divergent changeChanges to code should be kept local; too many diverse changes indicate poor structure
(6) Duplicated codeEradicate duplicated code whenever possible
(7) Feature EnvyClass features that use other class” features should be moved those other classes
(8) Inappropriate intimacyClasses should not associate with other classes excessively
(9) Incomplete library classAvoid adding a method you need (and which does not exist in a library class) to a random class
(10) Large classA class has too many methods
(11) Lazy classA class is doing too little to justify its existence
(12) Long methodA method is too large; it should be decomposed
(13) Long parameter listA method has too many parameters
(14) Message chainsAvoid long chains of message calls
(15) Middle manIf a class is delegating too much responsibility, should it exist?
(16) Parallel inheritance hierarchiesWhen you make a subclass of one class, you need to make a subclass of another
(17) Primitive obsessionOveruse of primitive types in a class
(18) Refused bequestIf inherited behavior is not being used, is inheritance necessary?
(19) Shotgun surgeryAvoid cascading changes; limit the number of classes that need to be changed
(20) Speculative generalityCode should not be added for “just in case” scenarios—it should solve current problems
(21) Switch statementsPolymorphism should be used instead of large switch statements
(22) Temporary fieldClasses should not contain unnecessary fields