r/learnprogramming • • Jul 12 '13

What are some bad coding habits you would recommend a beginner avoid getting into?

Whether they're stylistic habits or program design habits. I'm learning java and want to be sure to write my code as efficiently as possible to avoid lengthy code and poor design choices.

246 Upvotes

215 comments sorted by

View all comments

Show parent comment

4

u/istroll Jul 12 '13

To add to this. Comment why you did something, not necessarily what you did. I can see what you did, I want to know why you did it that way if it is unusual or if you found out some tricky issue that needed handling.

1

u/Dankleton Jul 12 '13

Agreed. I'd express it as "comments should say what code can't"

If you thought of 3 ways to achieve the same thing, write a comment about the two that you didn't use and why the way you chose was best. If you're using an unusual technique which is documented somewhere else, reference it.