is a term invented by the ExtremeProgramming
A code smell is a hint that something has gone wrong in the design. A code smell comes about when an experienced designer or coder visits a piece of code and feels that something could be done better. It's not the same as a FixMe
, which arises when they are certain it could be done better and are prepared to state how. Unlike a FixMe
, a code smeller doesn't necessarily know how to fix the problem, just that they feel uncomfortable about a bit of code, or algorithm, or inelegance, and think that should be looked at again.
A code smell is signified by the CodeBadge
SMELL in a comment in code. The tag MUST be accompanied by details of the smell; for example, this is a good smell:
# SMELL: The following undocumented function is only used in this module,
# but is not declared private (does not have a leading underscore
# in its name). It should really either be private, or should be fully
# documented as part of the interface to this module.
and this is a bad smell:
# SMELL: this could be coded better
Please make sure all your smells are good smells!
See also Wiki:CodeStench
- 12 Apr 2004