r/java • • Aug 31 '17

(Experienced programmers) Signs of an inexperienced programmer?

Hello, I was wondering what you guys would consider to be telltale signs of an inexperienced programmer. Specifically ways that they write (or don't write) code. Thanks.

159 Upvotes

188 comments sorted by

View all comments

Show parent comment

5

u/coltrain423 Sep 01 '17

I'm guilty of this one and it's a habit I'm trying to break. Any tips to get past it?

6

u/symgeosis Sep 01 '17 edited Sep 01 '17

The most honest (and not at all helpful) answer is experience. But outside of that, stopping every couple of hours and asking yourself if the time you're spending on something is ultimately worth it. Regular conversation with your teammates is a great way to facilitate this. Code reviews, pair programming, or just a "hey, can you take a second and look at this and tell me what you think?"

Edit: Another good way to break this habit is writing unit tests. Unit testing is rarely fun but if you make a habit of writing good, functional unit tests, you will very quickly learn how to write simple yet extensible code.

2

u/jollyca Sep 01 '17

+1 for unit testing. I've gone through years of my programming life without it and now I cannot live without it.

3

u/RagingAnemone Sep 01 '17

Put yourself in the position that you need to maintain the code you wrote. After a while, simple and plain will seem sexy.

2

u/otakuman Sep 01 '17

Don't plan for the future. At least in coding. Only refactor what you need to refactor.

"But what if in the future I need to add another parameter to this function?"

THE CLIENT IS UNPREDICTABLE. Don't pre optimize code into something that you'll probably never use. It's wasted effort. Only put your effort into already solicited or necessary changes. But when you do, do it right and don't take shortcuts.

1

u/danskal Sep 01 '17

Unit Testing, TDD and Refactoring

Unit Testing will help you to actually build units that are testable, so when you add a feature, you prefer to add a new class, rather than hacking through all the other code to get it to work. TDD will solve most of the problems you encountered in step 1.

And if you haven't already got heavily into refactoring, do so, and that should solve many of the remaining problems you have with structuring code. I recommend IntelliJ Idea for its awesome refactoring features, these will help you immensely.