r/learnprogramming • u/just_jesse • 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.
250
Upvotes
View all comments
Show parent comment
31
u/arimnaes Jul 12 '13
As a corollary to this - comments are just one solution to the problem of hard-to-understand code, so the more general advice would be "write code that's easy to understand." This encompasses several points, including but not limited to:
Comments are a subject on which there are as many opinions as there are programmers, but my opinion is that they should only be used as a last resort. Writing your code in such a way that it speaks for itself is always superior. Unlike code, comments can lie - they can and do get out of date as the code around them changes, and a misleading comment is worse than no comment at all.