You are on page 1of 2

Start Cleaning Up Level Up Your Code Style Use Comments Wisely

Avoid Unnecessary Comparisons Replace Magic Numbers with Constants Remove Superfluous Comments
Avoid Negations Favor Enums Over Integer Constants Remove Commented-Out Code
Return Boolean Expressions Directly Favor For-Each Over For Loops Replace Comments with Constants
Simplify Boolean Expressions Avoid Collection Modification During Iteration Replace Comments with Utility Methods
Avoid NullPointerException in Conditionals Avoid Compute-Intense Operations During Document Implementation Decisions
Avoid Switch Fallthrough Iteration Document Using Examples
Always Use Braces Group with New Lines Structure JavaDoc of Packages
Ensure Code Symmetry Favor Format Over Concatenation Structure JavaDoc of Classes and Interfaces
Favor Java API Over DIY Structure JavaDoc of Methods
Structure JavaDoc of Constructors

Name Things Right Prepare for Things Going Wrong Assert Things Going Right
Use Java Naming Conventions Fail Fast Structure Tests Into Given-When-Then
Follow Getter/Setter Conventions for Always Catch Most Specific Exception Use Meaningful Assertions
Frameworks Explain Cause in Message Expected Before Actual Value
Avoid Single-Letter Names Avoid Breaking the Cause Chain Use Reasonable Tolerance Values
Avoid Abbreviations Expose Cause in Variable Let JUnit Handle Exceptions
Avoid Meaningless Terms Always Check Type Before Cast Describe Your Tests
Use Domain Terminology Always Close Resources Favor Standalone Tests
Always Close Multiple Resources Parametrize Your Tests
Explain Empty Catch Cover the Edge Cases

Design Your Objects Let Your Data Flow Prepare for the Real World
Split Method with Boolean Parameters Favor Lambdas Over Anonymous Classes Use Static Code Analysis Tools
Split Method with Optional Parameters Favor Functional Over Imperative Style Agree On the Java Format in Your Team
Favor Abstract Over Concrete Types Favor Method References Over Lambdas Automate Your Build
Favor Immutable Over Mutable State Avoid Side Effects Use Continuous Integration
Combine State and Behavior Use Collect for Terminating Complex Streams Prepare for and Deliver Into Production
Avoid Leaking References Avoid Exceptions in Streams Favor Logging Over Console Output
Avoid Returning Null Favor Optional Over Null Minimize and Isolate Multithreaded Code
Avoid Optional Fields or Parameters Use High-Level Concurrency Abstractions
Use Optionals as Streams Speed Up Your Program
Know Your Falsehoods

You might also like