Skip to main content

Favour Numberscores

When dealing with numbers going above 6 digits, it can be difficult to quickly understand the exact figure they represent. By favouring underscores in our Java variables they become far more readable.

public final class TestNumberDefinitions {

public static int NORMAL_MILLION = 1000000;
public static int FORMATTED_MILLION = 1_000_000;

public static long NORMAL_BILLION = 1000000000;
public static long FORMATTED_BILLION = 1_000_000_000;

public static long NORMAL_TRILLION = 1000000000000;
public static long FORMATTED_TRILLION = 1_000_000_000_000;

This can also be utilised for standardised formats such as credit card numbers in your test cases.

public static long CREDIT_CARD_NUMBER = 0000_1111_2222_3333_4444;
public static int SORT_CODE = 12_34_56;