Code Guidelines

This is a general guide on how you can improve the code you write. Its main aim is to help you structure your code in a way that makes it easier for me to help you.

1. Use Correct Formatting

If there is one rule you follow, please let it be this. Correctly indent your code!

There are various “Style Guides” for code, all of which have subtle variations (two vs four space indentation, or dropping the opening bracket of a function to the next line are probably the two most common). Use any you prefer, but just stick to one.


Too many or not enough brackets are probably the most common problems. Correctly formatted code makes it blindingly obvious. It also makes your code a lot easier for others to understand.

2. Use Sensible Variable Names

Name your variable instances accordingly. Names like “myVar” and “anotherThing” don’t make much sense to anyone looking at your code…including you 24 hours after you wrote it.


Things will make a lot more sense the next time you look at it. Also, keep in mind others haven’t been watching over your shoulder every step of the way, so it might not be clear what the value of “myNumber” is, where it has come from or it’s intended use.


3. Correct Capitalisation

This is a more subtle one and while it doesn’t make and particular difference to the execution of your code, it does make a difference in the interpretation of those reading it.


More than anything, sticking with conventions is a good thing, after a while, this should become second nature.