Thursday, June 08, 2006

Code Smells

In the community of computer programming, code smell is a jargon term used among programmers to refer to a symptom that indicates something may be wrong. It generally indicates that the code should be refactored or the overall design should be reexamined. The term appears to have been coined by Kent Beck on WardsWiki. Usage of the term increased after it was featured in Refactoring. Improving the Design of Existing Code

Determining what is and is not a code smell is often a subject judgment, and will often vary by language, developer and development methodology.

What are the common code smells
Large method - a method, function, or procedure that has grown too large.
Large class - a class that has grown too large.
Feature envy - a class that uses methods of another class excessively.
Inappropriate intimacy - a class that has dependencies on implementation details of another class.
Refused bequeath - a class that overrides a method of a base class' such that the contract of the base class is not honored by derived class. See Liskov substitution principle.
Lazy class - a class that does too little.

No comments: