1. Names - tuansondinh/clean_code GitHub Wiki

1.1 Use intention-revealing names

BAD:

int d; // elapsed time in days ->

GOOD:

int elapsedTimeInDays;

1.2 Make clear disctinctions

BAD:

String theMessage, message; // -> what’s the difference? 

GOOD:

String logMessage, mailMessage;

1.3 Use pronounceable names

BAD

int dtaRcrd102 

GOOD:

int record

1.4 Use Searchable names:

BAD:

//single letters and numeric constants
int a;

GOOD:

int seconds;

1.5 Avoid Encodings (unnecessary complicated)

1.6 Avoid Member prefixes (unnecessary):

BAD:

String m_dsc;

GOOD:

String description;

1.7 Class names should be Substantives

1.8 Method names are verbs or verb phrases

1.9 Use get…, set…, is… prefixes for accessors, mutators and predicates

1.10 If constructors are overloaded, use static factory methods with names that describe the arguments

GOOD:

Complex fulcrumPoint = new Complex(23.0);

BETTER:

Complex fulcrumPoint = Complex.FromRealNumber(23.0); // To enforce their use, make constructor private

1.11 Avoid humorous names, no word plays

1.12 Use Solution Domain Names-> use computer science terms, if possible

1.13 Else -> Use Problem Domain Names