[go: up one dir, main page]

0% found this document useful (0 votes)
38 views3 pages

Clean Code Bullet Points

Clean code summary

Uploaded by

Benny Susanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Clean Code Bullet Points

Clean code summary

Uploaded by

Benny Susanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

- Meaningful Names

- Principles
- Intention revealing names
- Avoid disinformation
- Make meaningful distinction
- Use pronouncable names
- Use searchable names
- Avoid encodings
` - Avoid mental mapping
- Avoid names that are too generic
- One word for one concept
- Don't use the same word for 2 concepts
- Additionals
- Use solution domain names
- Use problem domain names
- Add meaningful context
- Don't add gratuitious context
- Class names
- Noun
- Static factory method for overloaded constructor
- Method names
- Verb

- Functions
- General principles
- Do one thing
- Including exception handling
- Shouldn't have a side effect
- Use return value instead of altering the argument
- Avoid duplications
- Extract and break the function
- Switch statements to polymorphism
- OCP and polymorphism
- CQRS
- Small
- One level abstraction below
- Top down narrative
- Arguments
- Max 2 arguments
- 1 is good, 0 is perfect
- Natural order
- Same level of abstraction
- Don't pass null
- Avoid flag arguments
- Break the functions
- Encapsulationg arguments
- Verbs and keywords in the function names
- Return value
- Don't return null
- Exception
- Prefer exceptions than error codes
- Extract try catch blocks

- Comments
- General principles
- Be careful of old comments that don't change
- Comments do not make up for bad code
- Explain yourself in the code
- Delete old commented code
- Good comments
- Legal comments
- Informative comments
- Explanation of intent
- Clarification
- Warning of consequences
- TODO comments
- Amplification
- Java docs in public API
- Bad comments
- Mumbling
- Redudant comments
- Misleading comments
- Mandated comments
- Journal comments
- Noise comments
- Nonlocal comments
- Too much information comments
- Inobvious comments

- Formatting
- Vertical formatting
- From general to detail, from top to bottom
- private functions below public functions
- variables should be near
- Conceptual affinity should be grouped together

- Objects and data structures


- public field in data structures
- it's not as simple as giving setter and getter for all fields
- Avoid hybrid of object and data structure
- OO vs Procedural
- OO is easier in term of adding new classes
- Procedural is easier in term of adding new functions
- The Law of Demeter
- Don't talk to strangers

- ErrorHandling
-Prefer exception than error code
-Write try-catch-finally first
-Use unchecked exceptions
- Open Closed Principle violation
- Provide context with exceptions
- Define Exception class in term of a caller needs
- Define the normal flow
- Convert exception handling to normal processing

- Boundaries
- Decouple thrid party code
- Exploring and learning boundaries
- Unit testing
- Interface for not yet existent code

- Classes
- Small
- Single Responsibility Principle
- Cohesion
- Intsnace variables used by the methods
- Organizing for a change
- OCP and polymorphism
- Isolating from a change
- Decouple using interface and abstract/more general claases

- Emergence
- Run all the tests
- Refractoring - noduplication
- Expresses the intent of the programmer
- Minimizes the number of classes and methods

You might also like