tags:

views:

229

answers:

6

My first thoughts are too many lines of code in a method. In most cases it's easy to break something apart into multiple methods at least.

I have many more, but that seems to be one of the simplest to avoid. It really bugs me to see a method with 1000 lines of code, this also seems to be a common problem. Anything where you need to scroll up/down is IMO should be begging you break it apart.

But having a list issues could help a lot of new developers learn to identify problems and provide some good practices.

+3  A: 

My favorite pet peeve is having many levels of indentation, ie large amounts of nested ifs and loops.

Worse than scrolling up and down has to be scrolling sideways!

My rule of thumb is usually 5 levels MAX. Any more and they should be getting refactored into new methods.

Cogsy
A: 

Not using exceptions for error management. It is so simpler to use exceptions, and so ugly to check each function return code (and forget half of them).

Jem
I disagree. http://www.joelonsoftware.com/items/2003/10/13.html
Graeme Perrow
I knew it and totally disagree with it.
Jem
A: 

I agree with you. Long methods are the simplest to avoid and essential for good code. My rule of thumb is that what the method does should be one obvious thing. If another developer has to ask what a method does after reading a method name, as a rule of thumb, it's doing too much. Of course it could also just be a bad name :)

Ankur
A: 

SQL injection is so easily aviodable that I don't understand why it ever shows on the screen.

And it's ugly, also.

And I'm astounded by non-solutions to it like quoting quotes or replacing INSERT/UPDATE/DELETE in statement. Damn, just use placeholders!

alamar
+1  A: 

Comments in code :P

But seriously, yeah, overly long methods are a nightmare. Incorrect code reuse, or total lack there of, is probably my biggest peeve though.

Phil
A: 

Single Responsibility Principle, so easy yet so often dont used.