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.

249 Upvotes

215 comments sorted by

View all comments

Show parent comment

10

u/kristianwilliams Jul 12 '13

God damn it, where were you a few months ago. Now I want to re-write half the code.

3

u/[deleted] Jul 12 '13

You'll learn from it and do better on your next project.

2

u/akerson Jul 12 '13

this is a form of refactoring (called extract method) and its one of the most common refactorings other than just renaming variables/fields/methods. Its never too late to refactor (: in fact a good practice (good subject for the thread!) is to constantly look at your code as if you were looking at it for the first time and seeing if you can tell your python/java/c#/whatever story a little clearer.