Code smells

From CSSEMediaWiki
(Redirected from Design smells)
Jump to: navigation, search

"If it stinks, change it." --Kent Beck's grandma, discussing child-rearing philosophy.

The term code smells was invented by Kent Beck. Chapter 3 of Martin Fowler 1999 (co-authored by Beck) provides a good intro.

Code smells motivate Refactoring.

Beck needed a word that gave developers a license to change code because they felt like it; because they sensed something was aesthetically wrong with the code. He didn't want something that suggested precision or direct quantifiablilty:

One thing we won't try to do here is give you precise criteria for when a Refactoring is overdue. What we will do is give you indications that there is trouble that can be solved by refactoring. You will have to develop your own sense of how many instance variables is too manyinstance variables and how many lines of code in a method are too many lines. -- Martin Fowler 1999, p75.

Ultimately, Christopher Alexander is lurking beneath this idea:

As far as I am concerned, patterns and XP are "the first try" and "the second try" of Kent Beck to put Christopher Alexander's ideas into practice. Both of them are derivatives of the Alexanderian philosophy.
On Kent's second try, he very carefully avoided mentioning Alexander. Perhaps he thought that Alexander just confused people, and that it was better to avoid ideas like the QWAN. So, he invented a whole bunch of new vocabulary to convey these ideas, things like "Code smells" and Do the simplest thing that could possibly work. -- Ralph Johnson


A alphabetical collection of code smells:


Personal tools