These are some of my "crap" indicators:
- No error detection/handling.
- Incorrect or non use of language features/standard libraries.
- Non understanding/incorrect use of programming paradigms (e.g. "is a", "uses a" ...).
- Useless, lack of, or bad documentation.
- Massive functions or methods
- Obfuscated code.
I hate it when:
Someone recreates functions because they were too distracted/overworked/lazy/dumb to see if a working function already existed.
Someone codes 5 lines to do something that could have been done with 1.
There are no naming conventions.
Someone uses one name for an object in one section of code but a different name in another but the two sections relate or interact. Duh!
There is no way to know who wrote the code or who made changes to it.
There is no formatting or inconsistent formatting.
Reiterate:
"more than 2 instructions in a line" is crap.
"no documentation or poor docs/comments" is crap.
> What code characteristics would make you say: “Pardon my French, but this code is crap!”
This is actually one of my favorite interview questions. I think lots of you guys already nailed the big ones: Functions with side effects. Big classes. Low cohesion. High coupling. Cut-paste-tweak duplication. Meaningless comments. Premature optimization. Premature generalization. Nonexistent error handling. Error handling everywhere. Empty catch blocks. Lots of "if" statements (special cases). Shared state concurrency.
I'll buck the trend and say the following aren't code smells, however:
* m_ notation. There are many abuses of Hungarian, but this isn't one of them.
* Multiple instructions on a line.
* Superficial layout inconsistencies. I don't think code has to cater to OCD sufferers to be considered "readable".
* Few comments. Well-written code doesn't need a lot of comments. (No comments at all is definitely a problem, but it's also one I've never run into. I have seen lots of problematic heavily commented code, though).
* Long functions. I look more at the number of locals and the level of indentation. Sometimes you really do need to do A, then B, then C, all the way to Z -- and in many cases, arbitrarily chopping it up into funclets is actually the wrong thing to do.
from http://beautifulcode.oreillynet.com/2007/09/pardon_my_french_but_this_code_1.php