Please enable JavaScript.
Coggle requires JavaScript to display documents.
Java Best Practices - Coggle Diagram
Java Best Practices
Data Types
Double precision
Int for Cents
BigDecimal
Concatenate many strings
Concatenate few Strings
StringBuilder
StringBuffer
StringJoiner
Data type for id's
UUID
Strings
Primitives over boxed primitives
Date and time challenges
java.time.*
Instant.now()
Methods
Method responsability
CSQ
Void method changes the state
Non-void compute and returns the result
Should not have undocumented side effects
Validate parameters
Objects.requireNonNull(argName)
IllegalArgumentExcetion(...)
Method signatures
Short and informative name with verbs
Interfaces over classes in param lists
Reduce number of parameters
Split methods
Create helper paraneter classes
Appropriate results
Return empty collections instead null
Returning a reasonable default
Throwing an exception
Using an Optional
Aways use
Override
Classes and interfaces
Favour immutability
Consider static factory methods
Consider using builders
Design utility classes correctly
Use dependency injection
Exceptions
Throw exceptions in if blocks