views:

1156

answers:

19

In relation to my other question:

http://stackoverflow.com/questions/432440/as-our-favorite-imperative-languages-gain-functional-constructs-should-loops-be

What's the politer word we can use for horrendous(for lack of better term again) codes when doing code reviews?

+2  A: 

I just usually say it's "not good" as I seldom find the need to be all that graphic about these things. So if I'm horrified it's "really not good" with a worried/frightened look on my face.

krosenvold
But "code smell" doesn't mean "not good". It means "this is something to be investigated". It could be "not good" or it could be perfectly fine. Sometimes, when something smells fishy, it's just a fish.
Jörg W Mittag
There's *always* something not good when I smell bad code. It may be as simple as a bad name that leads me to misunderstand the intended functionality or a logic error. it's never ok.
krosenvold
+1  A: 

maybe anti-pattern?

I dislike that wording. It comes to suggest that it's the opposite of a pattern where as a better term should mean a pattern that best be avoided.

shoosh
Even using the term "pattern" implies there is a certain thought-out logic to what is being done. I'm not sure I'm comfortable with that ;)
krosenvold
+8  A: 

I think you misunderstood my point in the other thread.

'Code smell' is a perfectly good phrase for code smells.

The situation you described with regard to non-functional constructs in C# is nowhere near strong enough to warrant the use of the term. A code smell means something's likely to be amiss. It might be handy to have a milder term for when everything's fine, but there may be opportunities to be smarter.

slim
Edited the answer in the other thread - hopefully it is now clearer.
slim
Right. Calling something a code smell is saying, "This doesn't look right," or "Is there a more idiomatic way to do this?"
Rob Kennedy
@Rob Kennedy: no, it isn't. A "code smell" is something to be investigated. It specifically does *not* mean that there's something wrong.
Jörg W Mittag
@Rob Kennedy: Of course "doesn't look right" may turn into "doesn't look right at first glance, but does make sense after all," e.g. using Duff's Device when aiming for speed.
Piskvor
+4  A: 

I'm fond of "this sucks".

Feel free to replace "sucks" with "blows", "is horrendous", "is garbage".

I believe that it's completely appropriate as well when it's clearly obvious in a review that the employee is not meeting the expectations that are set for them when it has been shown that they are completely capable of doing so.

It is because of the willingness on the part of the employee to come in below the level of expectation that I find this justifiable.

This is very different than an employee who has exhibited that they don't have the capability to meet the level of expectation, for that, I think that more gentile wording is definitely appropriate.

casperOne
"Code smell" is not a negative term. It just means that there is something to be investigated. "This sucks" OTOH *is* negative, so it's definitely *not* a synonym.
Jörg W Mittag
+7  A: 

Technical Debt? ;)
http://www.martinfowler.com/bliki/TechnicalDebt.html

shahkalpesh
Technical Debt is quite general and code smell is considered to be a subset of it. Technical Debt can also refer to the process (as in late check ins, lack of testing etc.).
Spoike
"Technical Debt" is a negative term, "code smell" is not. So, those two are definitely *not* synonyms.
Jörg W Mittag
@Jörg W Mittag: So you say "code smell" is a good thing?
Spoike
@Spoike: No. A "code smell" is something to be investigated. Period. It is neither good nor bad, and you don't know which one of the two it is, until it has been investigated. That smell could be a leaky pipe in your plumbing or it could be a delicious cheese.
Jörg W Mittag
+3  A: 

"code smell" is just fine.

hasen j
+12  A: 

Code fragrance?

Ian Hopkinson
Odour perhaps...
icelava
Codour, surely :-)
Arnout
Actually perhaps "Code Malodour" is more appropriate...
Ian Hopkinson
+9  A: 

[joke]

This block of code has fallen to the Dark Side.... beware the Dark Side of The Code.

Tight deadline leads to pressure, pressure leads to rash thinking, rash thinking leads to tight coupling, tight coupling leads to unmaintainable code, unmaintainable code leads to.... suffering.

[/joke]

Or, on a serious note,

This block of code appears to present opportunities or avenues for optimization....

icelava
"Code smell" is not a negative term. It just means that there is something to be investigated. The "Dark Side of the Code" OTOH *is* negative, so it's definitely *not* a synonym.
Jörg W Mittag
"Dark side" is meant as a joke. It must always be spoken with over-exaggerated acting.
icelava
The point is, a code smell is something that needs to be investigated. In your analogy: a code smell is a guy wearing a cloak. It could be a Jedi or a Sith -- you won't know which one until you take a closer look. However, a guy wearing a cloak is not necessarily a bad guy.
Jörg W Mittag
I do not perceive your analogy. I view it more in line with how the Jedi Council felt uneasy with Anakin Skywalker. "Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering. I sense much fear in you."
icelava
Therefore, while Fear does not directly meant Dark Side, it is signs of leading to the Dark Side. But then again, this is a suggestion in jest, not for use in a formal environment. Use among joking colleagues.
icelava
+2  A: 

And why not a simple "this code is bad" without forgetting the " because..."?

François
"smells" aren't necessarily "bad". They're a sign that you should investigate the code to see if it can be improved. Sometimes that godawful smell in your fridge is a nice cheese, sometimes it's not.
Roger Lipscombe
+4  A: 

Code can be rewritten to improve maintainance.

Naveen
+5  A: 

Code smell is not a pejorative, and it becomes a very non-confrontational term once the team understands what it means.

That being said, I occasionally use "goofy" or "unintuitive" when describing smelly code.

Daniel Auger
+6  A: 

Whatever fits the case:

  • confusing
  • fragile
  • too complex
  • likely to be a problem
  • needs refactoring
  • should be inspected more closely
  • there's duplication
  • is too large (for a method or class)

etc.

Note that these terms are not meant to define "code smell". They are common reasons I would call out code as having a code smell.


There have been several comments to various answers that "code smell" is not a negative term. While I agree that it does not necessarily mean "the code sucks" or that the code is awful (but sucky or awful code often does smell), it is an indication that an area of code may have problems and should be investigated more closely. Hmm, I'll add that one to the list of possible alternatives to "code smell".

So, on the scale of negativeity it tends a bit towards the neutral rather than toward the extreme negative. However, it's certainly not a positive term. I don't think you'll hear people say, "that's a fantastic code smell", except as a joke.

As the C2 wiki on refactoring says about "Code Smell":

A code smell is a hint that something has gone wrong somewhere in your code.

...

Calling something a CodeSmell is not an attack; it's simply a sign that a closer look is warranted.

I wouldn't say that anything on this list is an attack, except maybe "likely to be a problem". However, as for real life smells there are different degrees of "Code Smell" - there might be the smell of alcohol on someone's breath that's perfectly fine (just had a glass of wine with dinner or whatever), but there might be the smell of natural gas that means there's a big problem in the building.

Michael Burr
That doesn't make sense. First, "code smell" is not a negative term, however all terms you listed are negative. Second, "code smell" means that there is something to be investigated, which means you don't *know* yet, whether there is a problem or a refactoring opportunity.
Jörg W Mittag
"code smell" is not a negative term? It means the code looks suspect; that it looks like it might be a problem area. As far as the relative negativity of the terms, I think many people might be less defensive if their method "looks too complex" rather than "it has a code smell".
Michael Burr
I'm not saying the list of terms above is complete or define "code smell". But they are some of the reasons I might say "there's a code smell" here. The question was looking for other ways to call out a code smell.
Michael Burr
You write it yourself: a code smell means that there *might* be a problem and not that there *is* a problem. That is a very important difference. So important, in fact, that many jurisdictions put that distinction into their penal code, usually paraphrased as "innocent until proven guilty".
Jörg W Mittag
+19  A: 

A more polite word than code smell? If you are polite in any kind of code review then you are practically screwed. Political correctness in a code review session is an anti-pattern because in my experience it encourages destructive critisism. I'd suggest you just say it the way it is and give an example how to do it better. There are a bunch of code smells that are documented and widely discussed.

Got variable name that is non-descriptive? Just say so and give an example of a name that describes.

Got a condition that is never full-filled? Just say so and suggest to remove it.

Got a complex solution that can be refactored into something simple? Just say so and give an example how to simplify it.

Always be constructive than destructive in your criticism. If you are all political correct in a code review then two things will happen:

  1. Nobody will take you seriously and;
  2. Nothing will get done

We are human software developers and not politicians who think they are super human.

Spoike
I don't agree at all that being polite in a code review is a bad thing. People respond defensively to impolite feedback and nothing positive is accomplished. Constructive and valuable feedback can be delivered in a polite manner. However, I don't consider the term "code smell" impolite.
Jim Anderson
@Jim Anderson: I agree that the term "code smell" isn't impolite. I think the issue here is diplomatic in nature. If people respond defensively to feedback at all then something is wrong. "You are not your code". Only reason to talk back is if there is a valid reason for a piece of code to be there.
Spoike
You got my vote. I've always have gone on the saying "a teaspoon of prevention is worth a pound of cure"
monksy
Yes, but you don't have to say, "Horrible Code", particulary to someone who is getting on their feet. Slowly help, correct, and refractor with them and tell them what's wrong.Be Positive, not negative whenever possible.http://cheerusup.com/archives/260
CodeJoust
A: 

It's better than saying "Hey, I think we need to spend a little time defuctoring this code." :]

Andrew Kennan
A: 

another possibility is "alarming piece of code",

as in, it should make the zealot perfectionist inside you sound his sirens.

hasen j
+1  A: 

"Code smell" sounds neutral enough, but if you want to go PC all the way, try "differently-valuable statements or declarations," or DVSD for short. Algorithm for deriving:

  • "smell" is apparently an offensive word, so rewritten to "less-usable code"
  • "less-usable" may still offend somebody, so rewritten as "differently-valuable code"
  • "code" may offend somebody by alluding to ciphers and unreadability (also, it's a four-letter word! The horror!), rewritten to its somewhat vague definition.
  • make an acronym, conceptualizing the paradigm

Congratulations! You now have a completely non-offensive, non-descriptive and useless XTLA (Extended Three-Letter Acronym) to replace a commonly used idiom. The PHBs will love it.

Piskvor
A: 

A code smell is something which, while perhaps not evil in itself, is used by experienced programmers as a warning that something might be amiss. Often, this simply means the tell-tale signs left behind by a careless or amateurish programmer. If you want to avoid using the phrase "code smell", perhaps you could say "warning sign" or indeed "tell-tale".

Dominic Cronin
+1  A: 

Great alternatives to just saying "Code Smell" while not even worrying about being Politically Correct, is to mention the specific "smell" and mention a suggested solution. You can also give the developer a link to a website that explains the details so that the developer will also evangelize on creating good code.

This is a good reference about Code Smells and Refactoring:

http://c2.com/cgi/wiki?CodeSmell

If you are still worried about being Politically Correct, you don't have to, if you point out the Code Smells during the Code Review phase.

thenonhacker
A: 

Try:

 "Poorly Designed"

"A liability and a hazard waiting to happen"

Trying to be PC and non-conforntation about bugs lead to problems like this: Wired: gamma radiation

monksy
-1 for the comments... the smack was a joke. The others do not excuse poorly written code. As many of the others have mentioned, it is a slippery slope to try and remain PC about pointing out issues.
monksy