What is Quality C++?
Quality C++ is a living knowledge base that aims to provide a central point of reference of actionable advise for crafting high quality C++ code.
Code quality is the degree to which code can be safely and efficiently changed to meet user needs. This frames quality not just as correctness or adherence to rules, but as the capacity of code to evolve efficiently without causing unwanted side effects. In practice, this means writing code that is reliable, maintainable, and adaptable to user needs.
Quality is commonly defined as fitness-for-purpose. Software has the purpose of being valuable to its users. But users’ needs change, requirements evolve, and features must be added or adjusted to remain valuable over time. Change is central. This makes the software’s ability to adapt quickly a key aspect of its quality.
Analogies help explain code quality by comparing it to everyday domains where cleanliness, maintenance, and professionalism are expected parts of the job
Key Characteristics and Techniques
Section titled “Key Characteristics and Techniques”Below are core techniques and guidelines that contribute to high-quality C++ code. Each reduces risk of error or makes change easier:
Essential Guidelines for Quality C++
Section titled “Essential Guidelines for Quality C++”Safety and Correctness
Section titled “Safety and Correctness”- Use const correctness to improve code safety and clarity
- Use Static Analysis to guard correctness and consistency
- Use small and isolated experiments to resolve uncertainties
Managing Change and Complexity
Section titled “Managing Change and Complexity”- Write code that reads like the problem that it solves - Clarity over cleverness
- Make intentional design decisions - Every choice should have a reason
- Avoid just-in-case programming - Code what you need, when you need it
- Prefer value semantics over reference semantics
If you found this knowledge base useful, consider giving back — with money, feedback, or sharing.