Code smell is a symptom in the source code that indicates a deeper problem. Martin Fowler defined it as follows: "a code smell is a surface indication that usually corresponds to a deeper problem in the system". Design smells are the logical extension of the code smell concept and defined as follows - “design smells are certain structures in the design that indicate the violation of fundamental design principles and negatively impact design quality”.
For example, “Insufficient Modularization” (also known as “God Class”) is a frequently occurring design smell that arise either due to large number of methods in the class or high cumulative complexity (also referred as Weighted Methods per Class (WMC)) of the methods in the class. The presence of this smell indicates that the development team has not applied modularization principle sufficiently and hence the class can be further decomposed.
There are many side-effects when such a smell present in our code; for instance, it is difficult to understand and change a big class. If a change has been introduced without properly understanding the class, then the probability of introducing bugs is increased significantly. At the same time, more time and effort required to make a change in a large and complex class that clearly establishes how poor maintainability leads to poor productivity. It has been documented that the presence of design smells impacts understandability, flexibility, expandability, reusability, testability, and reliability of the software system.
Detecting design smells
One can identify design smells in one of the following ways:
- Manually – By analyzing code and design.
- Semi-automatically – By calculating metrics first and then inferring design smells by combining a few metrics.
- Automatically – By employing a design smell detection tool.
Often, design smells are identified manually where developers use their experience and domain knowledge to understand the existing design and identify potential refactoring candidate. However, for large codebase, the manual design smell detection is time consuming and not feasible. Additionally, many a times, developers know only a few design smells and not really aware of the extensive catalog of the smells. Such design smells remain unnoticed and undetected until developer faces maintainability problems due to the smells.
A developer may use metric tools such as NDepend and SourceMonitor to compute metrics first and then use and combine metrics with other metrics to infer design smells. For example, high Fan-in and Fan-out values indicate that the class is a Hub-like Modularization. Another example could be Deep Hierarchy that could be inferred by the metric DIT (Depth of Inheritance Tree). However, many design smells cannot be identified by metrics (or a combination of metrics). For instance, Rebellious Hierarchy design smell (also known as Refused bequest) cannot be inferred by metrics alone.
There are a few tools that are dedicatedly developed to detect design smells and improve the quality of the software design. Examples of such tools are Infusion and Designite. Infusion works with Java and C/C++ codebase where Designite targets C# code.
Let us understand step by step, how we can identify design smells using Designite for C# projects:


Santhakumar MunuswamyPosted Sep 17, 2015, 10:27 AM
Thanks for nice share
Mohammed IbrahimPosted Sep 15, 2015, 8:01 PM
nice
saurabh barthwalPosted Sep 15, 2015, 1:59 PM
nice sir
Sibeesh VenuPosted Sep 15, 2015, 4:44 AM
Nice Share
Karthikeyan KPosted Sep 15, 2015, 4:17 AM
Good one sir...Thanks for sharing
Humayun Kabir MamunPosted Sep 15, 2015, 2:52 AM
Nice...