StyleSheet - Geisonszo/TecProg-Emergo GitHub Wiki

1. Introduction

2. Source file basics

3. Source file structure

4. Formatting

5. Naming

6. Programming Practices

7. Javadoc

NOTES

  • IF / ELSE

When an else statement is a empty block, leave a comment. Example:

if (medicalRecord != null) {

      medicalRecord.setClass(ConfigController.this, MedicalRecordsController.class);
      startActivity(medicalRecord);
      finish();
    } else {

      // Nothing to do
    }
  • NEW BLOCK

Each time a new block or block-like construct is opened, one line is left in blank before the code block. Example:

public void setLatitude(Double latitude) {
    this.latitude = latitude;
}

public Double getLongitude() {
    return longitude;
}

All variables in a single block.

double smaller = 99999;
int position = 0;

for (int aux = 0 ; aux < closestHealthUnit.size() ; aux++) {

  if (closestHealthUnit.get(aux).getDistance() < smaller) {

    smaller = closestHealthUnit.get(aux).getDistance();
    position = aux;
  } else {

    /** nothing to do*/
  }
}