Fundamentals 7 min read

Eliminating YAGNI Smell, Using Comments Wisely, and Effective Code Review Practices

This article explains how to identify and remove YAGNI code smells, offers guidelines on when to write comments versus refactoring code, and provides practical tips for preparing, conducting, and learning from code reviews to improve software quality.

Continuous Delivery 2.0
Continuous Delivery 2.0
Continuous Delivery 2.0
Eliminating YAGNI Smell, Using Comments Wisely, and Effective Code Review Practices

The article, translated from Google’s testing blog, discusses three key aspects of software craftsmanship: eliminating the YAGNI (You Aren't Gonna Need It) code smell, deciding when to add comments, and conducting effective code reviews.

1. Eliminating YAGNI – Maintaining code incurs cost, so developers should only implement features when they are truly needed. The article shows a C++ example that creates unnecessary subclassing and dead code, then presents a refactored version that removes the superfluous hierarchy and simplifies logic. Additional YAGNI patterns listed include unreachable code, unnecessary subclassing, overly permissive visibility, and constant flags.

2. Using Comments – While good comments can clarify intent, they often signal that the code should be refactored to be self‑explanatory. The article recommends introducing explanatory variables, extracting methods, using descriptive names, and adding runtime checks instead of comments. It also outlines situations where comments are beneficial, such as explaining intent, protecting future maintainers, documenting assumptions, and justifying unconventional code.

3. Code Review Practices – Reviews may slow individual changes but improve overall quality. The author suggests preparing by re‑evaluating code, possibly holding informal design discussions, performing self‑reviews, keeping changes small and focused, and ensuring commit messages do not hide important information. After receiving feedback, developers should address the most serious issues first, re‑assess the code, and understand the reviewer’s rationale before making changes.

Overall, the piece provides actionable guidance for writing cleaner code, using comments judiciously, and leveraging code reviews as learning opportunities.

software engineeringCode ReviewBest Practicescode qualityYAGNI
Continuous Delivery 2.0
Written by

Continuous Delivery 2.0

Tech and case studies on organizational management, team management, and engineering efficiency

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.