Comments and Documentation
About
Why Comments and Documentation Matter
Types of Comments in Java
1. Single-line Comments
// Check if the user is already registered
if (userRepository.existsByEmail(email)) {
throw new DuplicateUserException("Email already exists");
}2. Multi-line Comments
3. Javadoc Comments
Commenting Best Practices
1. Explain "Why", not "What"
2. Use Complete Sentences with Proper Capitalization and Punctuation
3. Avoid Redundant Comments
4. Keep Comments Updated
5. Use TODOs and FIXMEs Appropriately
6. Avoid Over-commenting
Javadoc Best Practices
Documentation for Spring Boot Projects
1. Controllers and Endpoints
2. Configuration Properties
3. Domain and Utility Classes
Last updated