Clean Code #
Names++ #
Naming conventions:
- Choose your names thoughtfully
- Communicate your intent
- Avoid disinformation
- Pronounceable names
- Avoid encodings (eg. Hungarian Notation)
- Clean code should always read like well-written prose => Choose parts of speech well:
- Classes -> Nouns
- Variables -> Nouns
- Boolean variables -> Predicates (e.g.
isEmpty
) - Methods -> Verbs
- Methods with boolean as return values -> Predicates
- Enum -> Often adjectives
- Scope rules:
- Variables in a small scope: Short names
- Variables in a large scope: Long names
- Functions / classes in a small scope (e.g. private scope): Long names (names as documentation)
- Functions / classes in a large scope (e.g. public scope): Short names (willl probably be used by other people)
TDD #
Three Laws of TDD #
- Write no production code except to pass a failing test.
- Write only enough of a test to demonstrate a failure.
- Write only enough production code to pass the test.