Write your code as temporary comments and remove syntax errors as soon as you see them.
Here are a few tips I’ve been verbally passing on when teaching new develops at my Java-For-Testers, face-to-face training.

  • Write the code you want to see as comments first
  • Remove syntax errors as soon as you see them

Write the Code You Want to See as Comments First

For example, creating a blog comment, such as:

iterate over the list and print the name of each object in the list
and assert that when I call getAge for each object it is greater than 18

The reason for doing this is that learning Java is hard enough. You find yourself with all kinds of questions:

  • Write the code you want to see as comments first
  • Remove syntax errors as soon as you see them

You are trying to remember a whole bunch of stuff.

Writing down what you are trying to achieve means that you don’t have to keep that in your head at the same time.

Eventually, you will stop doing this. And you will want to delete the comments when you are finished.

But, I’ve seen this help people because this it stops people from getting too far lost.

Remove Syntax Errors as Soon as You See Them

When people don’t do this, they end up writing a bunch of code, and then, none of it works. And, it can be hard to resolve.

As soon as you see a syntax error, fix it. This will allow you to write code and harness code completion.

Sometimes, that means I’ll write "" because I just want the syntax error to go away and I haven’t decided on the data yet.

Sometimes, that means I’ll pass the null as the argument because I don’t know what it should be yet, but I know it needs to be there.

Then, when the line of code is syntactically correct, I make it semantically correct.

This also helps when you are using the IDE to write code with “Alt+Enter,” the more syntactically correct it is, the more the IDE will generate the code you want to see.

And using the IDE to write your code can help avoid syntax errors.


Those are the first two tips that come to mind. I’ll try to make another list the next time I teach the training. This is just a list of simple things that can avoid the enormous, cognitive workload associated with learning code.

*Originally published by Alan Richardson at https://dzone.com

Learn More

Complete Java Masterclass

Complete Step By Step Java For Testers

Java Web Service Complete Guide - SOAP + REST + Buide App

Selenium WebDriver with Java - Basics to Advanced& Interview

Java Persistence: Hibernate and JPA Fundamentals

Java Swing (GUI) Programming: From Beginner to Expert

Java Basics: Learn to Code the Right Way


Two Java Beginner Coding Tips
15 Likes32.95 GEEK