Some time ago, Phil Factor wrote his booklet 'SQL Code Smells', collecting together a whole range of SQL Coding practices that could be considered to indicate the need for a review of the code. If you look at the class and say “well, I will have to change these 3 methods every time I get a new database, I have to change these 4 methods when month end process changes” you likely have a situation in which 2 classes is better than one. Code smells, or bad smells in code, refer to symptoms in code that may indicate deeper problems. Divergent change occurs when one class is commonly changed in different ways for different reasons. - Shotgun Surgery Code Smell It is the exact opposite of divergent change. This smell is evident when you must change lots of pieces of code in different places simply to add a new or extended piece of behavior. Detecting Code Smells Find them and removing or replacing them is very important for the overall quality of the code. Looking at the code above, you can see 11 different if statements, many of which check more than one condition. When you have to change the same class for different reasons — and each time a different part — you may have to deal with divergent change. When divergent change code smell is present, multiple changes are made to a single class. It was published as 119 code smells, even though there were 120 of them at the time. Not all code smells should be “fixed” – sometimes code is perfectly acceptable in its current form. Code Smells. There are various types of code smells. But when shotgun surgery code smell is present, when a single change is made to multiple classes when there is excessive coupling between the classes and a single responsibility is shared among multiple classes. Divergent changes occurs when one class is commonly changed in different ways for different reasons. Mutability was causing some of the confusion, so now that we’ve simplified the method to minimize mutability, let’s take a closer look at the rest of the code. Two contain a break, one a return. Bonus Code Smell Of The Week - Divergent Change (Clean Separation) So once again with the Account example, only this time the two concerns (account logic and XML serialization) are cleanly seperated so that Account has zero knowledge of it. This code smell will make you change many classes for one single reason which means that many classes have the same reason to change in order to apply one behaviour. Removing code smell is an important task and can be done using automated code review tools. The Smell: If Statements. They’re a diagnostic tool used when considering refactoring software to improve its design. I'm often asked why ... Watch out for large conditional logic blocks, particularly blocks that tend to grow larger or change significantly over time. 1. Phil Factor has continued to collect them and the current state of the art is reflected in this article. Code smells occur when code is not written using fundamental standards. This code smell is a little tricky to detect because this happens when a subclass doesn't use all the behaviors of its parent class. Consider alternative object-oriented approaches such as decorator, strategy, or state. [F 80] Refused Bequest: This smell results from inheriting code you don't want.