7

I was about to ask a question in the Software Engineering stack exchange channel. I noticed that tags exist for both anti-pattern and code smell.

But isnt every anti-pattern a code smell? and isnt every code smell an anti-pattern?

| |
  • Neither of these terms are "officially recognized." They're just slang terms software developers use to describe code they don't like. – Robert Harvey Aug 18 at 21:10
16

But isnt every anti-pattern a code smell?

If the anti-pattern is directly related to code, yes. But there are also other types of anti-patterns (e.g. Project Management AntiPatterns).

and isnt every code smell an anti-pattern?

No, not necessarily. It's not always a pattern if you find simply badly written code.

So no, these aren't synonyms, and having a separate tag for each is justified.

| |
10

I should probably just give up trying to explain this, but code smells as the term originally was coined aren't necessarily bad code. They are probable cause to investigate further. They are a hint that something might be wrong, they are not always the something wrong. Someone needs to come up with a name that conveys that better.

For example, comments are considered a code smell, but really they are deodorant, covering up the actual smell. Notice each of those code smells listed have a "When to Ignore" section.

| |
7

Karl Bielefeldt already explains that in his answer, but I would like to reiterate, because I often see this used wrong:

  • An anti-pattern is something that is definitely wrong.
  • A code smell is something that should be investigated. It might be perfectly okay.

Kent Beck actually credits the to his mother. The idea is: when it smells, it might be rotten or it might be cheese. You don't know until you investigate.

| |
  • .. and then there is the misuse of the term 'anti-pattern' for what are actually errors and bugs (but that's outside of the scope of the question). – Jan Doggen Aug 7 at 7:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .