Code Quality
There are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies. - C.A.R. HoareA designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. - Antoine de Saint-Exupery
Coupling and Cohesion
Code Metrics
- Code Metrics (note: we will stick to metrics that relate to readability and maintenance rather than business or run-time efficiency metrics)
- Number of lines of code (per method, per class)
- Cyclomatic complexity - wikipedia
- Dependency graph example (originally from http://www.ndepend.com/SampleReports/OnNUnitNew/ComponentDependenciesDiagram.png)
Code Smells
- Code smell definition and practices for dealing with them
- Wikipedia (see list of common code smells)
- Breakdown of code smells within a class vs. code smells between classes
- Taxonomy of Code Smells
Anti-patterns
- Definition
- Wiki-books Introduction to Software Engineering/Architecture/Anti-Patterns (list with short descriptions)
- SourceMaking (sorted by category, each with a specific example on a subpage)
- Anti Patterns Catalog (list with examples and discussion pages)
Refactoring
- What is refactoring? - restructuring existing computer code without changing its external behavior
- Why Refactor?
- Refactoring improves the design of software -without refactoring, a design will "decay" as people make changes to a software system
- Refactoring makes software easier to understand - because structure is improved, duplicated code is eliminated, etc.
- Refactoring helps you find bugs - refactoring promotes a deep understanding of the code at hand, and this understanding aids the programmer in finding bugs and anticipating potential bugs
- Refactoring helps you program faster - because a good design enables progress
- When to refactor?
- Outcomes from tools that do static code analysis
- When you know the initial implementation was poorly planned or was rushed
- When your boss says so
- Choosing what to refactor and how to do it
- Files with poor metrics from code analysis
- Code smells
Technical Debt
- Wikipedia - eventual consequences of poor software architecture and software development within a codebase
- Martin Fowler on technical debt
- Quadrants
Other thoughts and opinions on code quality, some with code samples
- All Software Sucks, but I care.
- Constructive Criticism
- Software Craftmanship + first few responses
- How not to program: http://www.dreamincode.net/forums/topic/194878-xna-animated-sprite/ - Note, this code is not bad by current practices. There is much worse code.
- Blog with a counter argument to writing clean code
- Best practices for naming conventions in C#
- Some random blog on being a professional programmer and the "discussion" and lack of comprehension in some of the comments.