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 ?


3 Answers 3


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, 2017 at 13:13
  • 1
    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. Jun 3, 2017 at 20:06

I'm writing my answer because I think that the two concepts can be confusing and I want to state a list of clear and direct difference.


Facts: Anti-patterns "the fact that it looks like a good solution is its essential danger" 1. On the other side, "smell is by definition something that's quick to spot" and "it's easy for inexperienced people to spot them" 2.

The gist: anti-patterns are more abstract, more subtle, more difficult to recognise. Smells are easier and quicker to see or smell.

Facts: Code smells "they are often an indicator of a problem rather than the problem themselves" and "smells don't always indicate a problem" 2

The gist: Code smells are symptoms that could hint to some more profound; anti-patterns are more profound themselves.


  1. https://martinfowler.com/bliki/AntiPattern.html
  2. https://martinfowler.com/bliki/CodeSmell.html

"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.

  • 5
    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.) Jun 3, 2017 at 8:05
  • 4
    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, 2017 at 17:23
  • 3
    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. Jun 4, 2017 at 1:28

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