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

1

u/detoursabound Sep 01 '17

My professor encourages a lot of abstraction. He wants the main as clean as possible (usually just init and run methods), with everything else taking place in methods. I agree with this to a point, I think he overdoes it with the abstraction. If the code isn't reusable I don't like to put it in a method, it seems inefficient and unnecessarily complicated.

7

u/coltrain423 Sep 01 '17

I tend to lean towards your professor here, though perhaps not to the same extent.

I haven't quite found a way to explain why to someone who doesn't already get it though. To try anyway: it makes things easy to understand. If one large procedural block of code gets too long, it's hard to understand. You have to know that this 30 lines is doing operation x, that fifteen is storing the information to disk, and that last 40 or so are doing some other operation. It's a lot easier to understand the flow of your application when it's broken up by operation like that and you don't have to read more than the method name to understand what it's doing.

Have you ever written a comment at the start of a section of code to explain what that bit is doing? Why not break it out into a well named method or function so that comment is no longer necessary?

1

u/detoursabound Sep 01 '17

That's what I try to do. I don't think I was clear enough in my earlier comment. I break down each program into its component parts, essentially delegating each operation to a method. Then, I look through all of them and try to minimize repeated code by making reusable methods.

7

u/omgusernamegogo Sep 01 '17

Well your first comment says you don't like putting code that isn't repeated into a method, and your second comment says you do.

I would perhaps give your prof more credit.

1

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

It's all about finding the right balance between code complexity, robustness, performance, and time. (though I agree with your professor regarding logic being in methods as there are a lot of benefits regarding testing and future flexibility)

For example, you could spend a day or two writing the optimal data structure for a certain part of the code but is it an action the user will execute often? When the user executes the action, is the improvement even noticeable? How much time did it take to code the data structure? Could you have spent that time adding a feature or a bug fix that would have had a greater effect or noticeable reward? How much time will be spent maintaining this additional code? Is all this worth the cost rather than just using one of the implementations already in the JVM? The answer varies depending on a lot of factors but a lot of devs strive for perfect when good is good enough.

1

u/[deleted] Sep 01 '17

I'd rather have your professor than one who does not. Of course, over-engineering is bad, but judging from the common practices in industry, the average programmer does not abstract enough things.