The Diminishing Return on Code Uniformity
Filed Under Code, Quality Controls, Software ProcessLast week Steve Rowe had a nice discussion on the question – Is There Value In Code Uniformity? Although I left a comment, I thought I would expand upon my thoughts a little more.
I do agree that every team must have (and enforce) some basic standards of code uniformity. These may include items such as:
- Use PascalCase over camelCasing or Hungarian notation
- Prefer language keywords over hard types (as in – int not Int32)
- No single line if statements or use of ternary operators such as ?
- All references to class member variables will be prefixed with this.
These types of standards give a clear outline of the fundamentals of code cleanliness and uniformity that can aid in a team environment.
However, often I see team leads attempting to micro-manage these coding standards. The majority of these standards have very low impact on overall readability and maintainability. I have see religious wars break out over stupid standards such as:
- { on new line or same line
- _ or m_ in front of private variables
- The order of class member declarations (private vars, ctors, props, methods [in alphabetical order], etc…)
It is unfortunate that I see teams creating standards not only littered with these types of rules, but fore-running as the core foundation. These types of standards do have worth, but must be enforced with a much lighter touch as policing these types of infractions just does not yield overall benefit to the application.
In the large scheme of things these types of code uniformity infractions are small potatoes. It is the equivalent of creating a standard way of monotone communication for optimal office efficiency – yeah ok.
I am not advocating that we should not have coding standards nor that they should not be enforced by frequent code inspections; however, I am of the belief that developers write code with minor deviations that show the same uniqueness you would see in articulated words or drawn pictures. Instead of attempting to find a happy standard, let’s celebrate our minor differences in writing code and be more adaptive to different flavors.
Sometimes the small things do matter – but not in this case.