12

Is there such a thing as too much uniformity? Where I work we of course have standards including naming conventions, architectures, frameworks to leverage etc. However lately there has been a lot of critiquing of things I would consider more style.

For example writing if statements in multiple lines vs one line, using the c# ?? null-coalescing operator instead of say == null, amounts of spacing for indentations etc.

It seems to me this starts getting more into a personal style choice and doesn't need to be uniform across a team or company. What one person thinks reads more clearly another may not. Is there some value to this "extra" uniformity?

Robert Harvey
  • 200,592
Gratzy
  • 3,738

5 Answers5

16

Uniformity is not a problem (it's good) but rigidity or inflexibility can be. If in striving for uniformity you become dogmatic then the harm you are doing to the team may be greater than the good that comes from the (possibly) resulting uniformity.

It's best just to set basic style for the most important things (naming and capitalization standards, indentation, new-lines and bracket placement, etc.), set recommendations for less important things (if statement format, other whitespace around parentheses, etc.), and then not worry about the rest.

Nicole
  • 28,243
7

When potentially dozens of people are working on a project over the years of its lifespan, it sometimes gets confusing when you have to jump styles. Imagine reading a book where different chapters are written by different authors who only somewhat maintain writing style. It's possible, but it's annoying.

Most IDEs can enforce styles these days, so if necessary you can distribute (as a part of the project source code) an IDE preferences file that specifies the chosen coding style and have everyone install it and use it to format the code they're writing. I bet there's even ways to have code reformatted/styled on check-in (though I haven't had to investigate this yet).

3

One case of over-uniformity I've seen is to have a single standard that applies to all programming languages regardless of appropriateness:

  • Discouraging goto even in languages like C without try...catch.
  • Using InitialCaps names (as in Microsoft's MFC and C#) in JavaScript where the standard library is initialLowerCase.
dan04
  • 3,957
2

I don't think there is such a thing as too much uniformity. However, I often find that too much SPECIFICITY in coding standards. The benefits of everyone putting the opening brace on a separate line are dubious at best and don't outweigh the time spent arguing about it or fixing cosmetic issues in code.

JohnFx
  • 19,040
2

I'd have 2 arguments for the uniformity:

  • Promoting collective ownership. That someone can go edit the code of someone else without fearing that someone's "baby" is about to be hurt by the change. A kind of "We're all in this together" mentality.

  • Ease of adding to it. If something has already been done somewhere else then this can be taken and re-used possibly. Certain conventions can help make things easier to read or change sometimes so this is another benefit to my mind.

JB King
  • 16,775