Code Smells and their Detection
Code smells violate established design principles and indicate suboptimal design or implementation choices within the codebase. They can be categorized based on their level of abstraction, granularity, and scope.
Architecture smells
The quality of your architecture decides vital quality parameters of your software product.
Cyclic Dependency: This smell arises when two or more architecture components depend on each other directly or indirectly.
Unstable Dependency: This smell arises when a component depends on other components that are less stable than itself.
Ambiguous Interface: This smell arises when a component offers only a single, general entry-point into the component.
God Component: This smell occurs when a component is excessively large either in the terms of LOC or number of classes.
Feature Concentration: This smell occurs when a component realizes more than one architectural concern/feature.
Scattered Functionality: This smell arises when multiple components are responsible for realizing the same high-level concern.
Dense Structure: This smell arises when components have excessive and dense dependencies without any particular structure.
Design smells
Design smells refer to structural issues in software design that stem from violations of core design principles, leading to reduced design quality and maintainability. (from Refactoring for Software Design Smells: Managing Technical Debt)
Abstraction Design Smells: Imperative Abstraction, Unnecessary Abstraction, Multifaceted Abstraction, Unutilized Abstraction, Duplicate Abstraction, Feature Envy.
Encapsulation Design Smells: Deficient Encapsulation, Unexploited Encapsulation.
Modularization Design Smells: Broken Modularization, Insufficient Modularization, Hub-like Modularization, Cyclically-dependent Modularization.
Hierarchy Design Smells: Wide Hierarchy, Deep Hierarchy, Multipath Hierarchy, Cyclic Hierarchy, Unfactored Hierarchy, Rebellious Hierarchy, Missing Hierarchy, Broken Hierarchy.
Implementation smells
Abstract Function Call From Constructor
Complex Conditional
Complex Method
Empty catch clause
Long Identifier
Long Method
Long Parameter List
Long Statement
Magic Number
Missing default
Duplicate Code
Testability smells
Testability refers to the degree to which the development of test cases can be facilitated by the software design choices.
Hard-wired dependencies
Global state
Excessive dependency
Law of Demeter violation
Detect test smells
Test smells are defined as bad programming practices in unit test code that indicate potential design problems in the test code.
Assertion roulette
Conditional test logic
Constructor initialization
Eager test
Empty test
Exception handling
Ignored test
Unknown test
Several academic and professional tools are available for detecting code smells. DCode integrates with Designite tools, which identify a comprehensive range of architecture, design, testability, test, and implementation smells. These tools also compute relevant object-oriented quality metrics. Designite tools currently support projects written in C#, Java, and Python.