Programming Guidelines - rekhyt75/TUBS GitHub Wiki

#Programming Guidelines

Add comments

Add comment to code help other contributors to understand better the code

Logging framework

Neither System.out nor printStackTrace are allowed. The internal logging framework must be used for all kinds of logs or tracing messages. Follows some examples: //TO_DO ad examples

Do not use primiteves

Primitives data types must be replaced by BigDecimal and BigInteger wherever is possible . For recipe calculation and in general for mathematical operation BigDecimal and BigInteger must be used. Primitives can be used where precision is not required or data is not showed onto GUI.

The following code is OK.

for(int i=1; i<11; i++){
    System.out.println("Count is: " + i);
}

The following code is NOT valid.

double a = 0.02;
double b = 0.03;
double c = b - a;

because the value of c is 0.009999999999999998 and must be replaced with

BigDecimal a = new BigDecimal("0.02");
BigDecimal b = new BigDecimal("0.03");
BigDecimal c = b.subtract(a);