CodeSmells signal the existence of problems.
CodeDeodorants remove the smell without removing the cause.
Examples:
- Comments
- Vertical whitespace "for clarity" (If it needs vertical whitespace, it probably actually needs an IntentionRevealingSelector)
- Using redundant access specifiers to 'partition' a class into multiple pieces instead of decomposing it
- #region (C# only)
- ...
DesignPatterns often serve as
CodeDeodorant for
LanguageSmells.
The root cause of
CodeSmells is
UnconsciousIncompetence on the part of programmers -
NoHintingNeeded.
CodeDeodorants (I like it! Funny!) attempt to cover the smell instead of removing it via
ReFactoring.
Some
CommercialDeodorants which claim to remove the smells work by
AnesthetizingTheNose. They are
NasalAnesthetics. Therefore we should consider as
CodeDeodorant's methods which put your method for
DetectingCodeSmells
OutOfAction, without removing the root cause or the smell itself.
- How do you detect the code smell of 'code not used anymore'? I recently removed five unused subroutines which called each other from a large project. Orphan subroutines are 'smellier' than little orphaned groups. When orphaned subroutines call each other the smell is still there, but is less pungent.
- I suspect the solution here is to employ the same logic as that used to identify WalledGardens in Wiki. By examining the call tree of the code, you ought to be able to produce a report of all code which is referenced, directly or indirectly, from the root of the program's call tree. If you employ dynamically loaded modules, this gets more complex, because now you need to examine configuration scripts too. Automation may not yield a 100% accuracy, but it can definitely help immensely.
- How do you detect the code smell of ParallelInheritanceHierarchies? If the naming is sufficiently dissimilar, you may not smell that smell. Someone who goes through renaming one of the hierarchies may be removing your ability to smell the smell.
It would be interesting to have some examples where automated tools for detecting
CodeSmells are rendered insensitive e.g. by macros or by other means....
CodeDeodorant may be neccessary if
CodeSmell is imminent (e.g. due to
LanguageSmells). This may be reason for
CommentTheWhy.
See:
CodePerfume