Coding Conventions and Standards we are to follow - adrielFab/Kaasch GitHub Wiki

Coding conventions and standards we are to follow

Below is a list of the coding conventions we are to follow. In addition, I will be listing preferred standards that we are to follow.

Source Files

All source files should begin with a c-style comment

/*
* Classname 
* 
* Version information
*
* Date
* 
* Copyright notice
*/ 

Packages and Imports

Start with package, a new line, then the imports

\package java.awt;

import java.awt.peer.CanvasPeer;
import java.anotherPackage.Carl;

Conditions and Loops

After closing parenthesis, there should be a space right before the opening curly bracket

if (condition) {
    System.out.println("Code inside condition starts here");
}

for (int i = 0; i < str.length(); i++) {
    System.out.print("Notice the spaces in the for-loop");
}

Also applies for classes, interfaces... anything using curly brackets as containers

Fields

  • One declaration per line unless of same type
String startAddress;
String endAddress;
//Or
String startAddress; endAddress; //notice the space
  • Constants are all caps : int MAX_WIDTH
  • All long fields will follow camelCase, for example -> editTextField
  • Android Studio widget variables are camel-case. No nicknames or aliases.
textViewTitle;
buttonSubmit;

//NOT 
Button_Submit;
button-submit;
ButtonSubmit;
btnSubmit;

FOLLOW THE CAMEL!!!