I am trying to understand the difference between these two terms. In some contexts that these two terms have been used interchangeably. What is the exact difference between these two terms ?


A Code Smell is something which should be investigated. Is it a piece of delicious cheese or is it rotten beef? An Anti-Pattern is just bad, a Code Smell is something which may or may not be bad.

This quote from the Wiki page is extremely relevant (the emphasis is from the original source):

Note that a CodeSmell is a hint that something might be wrong, not a certainty. A perfectly good idiom may be considered a CodeSmell because it's often misused, or because there's a simpler alternative that works in most cases. Calling something a CodeSmell is not an attack; it's simply a sign that a closer look is warranted.

An Anti-Pattern is a Pattern which, when you follow it, will lead you towards a worse design in the same way that a Pattern will lead you towards a better design:

An AntiPattern is a pattern that tells how to go from a problem to a bad solution. […] In the old days, we used to just call these 'bad ideas'. The new name is much more diplomatic.

  • S/will lead/will often lead/ – Basilevs Jun 3 '17 at 13:13
  • At least as it was originally defined, "anti-pattern" was not simply a mistake. It was specifically restricted to a design that originally seemed like it would be good, was done intentionally, and eventually worked out poorly. This is rather different from a common case of simply doing something without thinking about it much (if at all) and it turns out that it merited real thought. – Jerry Coffin Jun 3 '17 at 20:06

"Code smells" are an insulting judgement of someone's code, based on blindly applying some rule without understanding it. It's a word that is used by some anti-social programmers. NEVER use this word in my presence. You will not be happy.

A "pattern" is something that many people use to solve some kind of problem. An "anti-pattern" is a pattern that doesn't work and gets you into trouble. "Pattern" is often also used to mean "a pattern that works" since things that don't work usually don't become patterns.

  • 2
    How do you reconcile your comments on code smells with this quote from the definition? "Note that a CodeSmell is a hint that something might be wrong, not a certainty." (Emphasis in the original source.) "Calling something a CodeSmell is not an attack; it's simply a sign that a closer look is warranted." (Emphasis mine.) – Jörg W Mittag Jun 3 '17 at 8:05
  • 2
    The fact you may have teammates who are abusing the word "code smell" the way you described it does not mean the rest of the world abuses that term the same way. I recommend to start with Wikipedia to learn how that term is used by responsible, educated people. – Doc Brown Jun 3 '17 at 17:23
  • 1
    I would recommend the Wiki over Wikipedia for terms from the agile, patterns, and OO community. The Wiki was invented and put up specifically for discussing Design Patterns and it's also where Agile got started, so a lot of the original sources are on there. – Jörg W Mittag Jun 4 '17 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.