When you are writing code, you are writing it for 2 parties.  The first party is the compiler, which converts code into the computers natural language. The second party are other programmers! Other people will likely be using your code, updating your code or learning from your code. It is important that you have written your code so it  can be easily read.  

 

Indentation:

Indenting your code allows other programmers to see the start and end of code blocks. You should use 1 tab or 4 spaces to indent the code inside a code block. Code blocks are generally between a set of curly brackets, { }

Examples:

if ( testVariable == true ) {

indentSomeCode( );

}

 

public void callSomeFunction( ) {

var[] indentSomeCode;

for ( int pos = 0; pos < indentSomeCode.length; pos++ ) {

callSomeFunction( );

}

}

 

Naming Convention:

When defining variables, functions and classes, you should make your names meaningful and understandable. when other programmers read your code it should be obvious what the code is intended for through the names of function and variables.

The standard convention is to use CamelCase, where you capitalize the first letter of every word in your name.  The current convention is to use a lower case letter for the first word in variables and functions and to use a capital for classes.

Variable Names:

int studentNumber;

String firstName;

String[] strNamesArray;

Function Names:

public int addTwoNumbers(int firstValue, int secondValue) 

private void validateData()

public String getFirstName()

Class Names:

public Student

public CalculatorController

 

Comments:

Coming Soon...