Two Java Beginner Coding Tips

Two Java Beginner Coding Tips

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 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.

Conclusion

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

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios