Member-only story
Commenting in Android: Clean Code Best Practices
3 min readJun 7, 2025
Writing clean, maintainable code in Android (especially with Kotlin) doesn’t just mean getting rid of bugs — it means writing code that reads like prose, behaves predictably, and evolves gracefully. One of the most misunderstood parts of clean code is comments.
While many developers rely on comments to explain logic, clean code principles often recommend avoiding them unless absolutely necessary.
So… when should you comment, and when should you avoid it entirely?
Let’s break it down!
Why Clean Code Dislikes Comments
Legendary software craftsman Robert C. Martin (Uncle Bob) said:
“Don’t comment bad code — rewrite it.”
Here’s why overusing comments is problematic:
- Comments lie: They often become outdated or incorrect after a refactor.
- Code duplication: A comment might repeat what the code already says.
- Clutter: Excessive comments reduce readability instead of improving it.
- Poor design patch: Comments are often used to explain bad code, instead of fixing it.