Jens Schauder is software developer since 1997. He loves software development for the constant challenges and constantly changing environment. A great chance to learn and teach. He is also blogger, author of various articles and speaker at conferences. Jens is a DZone MVB and is not an employee of DZone and has posted 84 posts at DZone. You can read more from them at their website. View Full User Profile

Coding Standards ARE Important

02.12.2013
| 3500 views |
  • submit to reddit

Zac Gery thinks when it comes to coding standards:

in most circumstances the unrecognized pitfalls outweigh the benefits

I strongly disagree! But lets go through his points one by one:

Some team members equate coding standards to a lack of confidence in his/her abilities. Others find standards such as spacing and/or comments to be micro-managing.

Pardon me? If you have team members that have an issue adhering to simple team rules like “we want our {s on a separate line” and consider that a personal insult you have some serious issue in your team. Software development is a team effort. If you are working in a team you have to adhere to the rules of the team, no matter if they are written down or exist as implicit knowledge of the team.

Coding standards stifle and discourage coding creativity. Some of the best code comes from an unfiltered mind.
They create unneeded stress within a team as members disagree with various standards. These discussions can spiral into negative, unproductive debates.

Hands up: Who considers it an important part of their creativity to decide on every line how far to indent it? That’s what I thought. Discussions about coding standards? Yup, we have those too. But there is no spiral involved. Somebody brings up a concern like “I think we should stop prefixing field access with this.” We exchange arguments and opinions. Then we decide. End of debate. Again, if you have constant fights in your team about this kind of thing, you have a serious problem in your team and its not the code style guide.

Each new rule adds to the overall complexity of implementation, enforcement, and maintenance of coding standards.

99% of all coding standards get implemented and maintained by your code formatter. The stuff that doesn’t gets enforced by tools like checkstyle. Therefor there really isn’t any relevant effort involved. Coding standards reduce these efforts because it prevents formatting wars and reduces the time needed for reading code.

Each concession to a rule devalues the overall purpose of coding standards.

That’s like saying we should legalize murder since every killing devalues the laws against it. Doesn’t make any sense.

Coding standards distract from the larger goal of building, testing, and releasing functionality in a timely manner.

I still don’t get it. How is it less distracting, when I have to check if a token references a class or a field just by checking if it starts with an upper case character? How is it less distracting, when I have to search for matching curly braces because the code is not properly indented?

Deciding how to handle existing code that pre-dates the creation of a standard is a winless battle.

Again, why battle? Have a discussion, make a decision, be done with it. Get used to it, this is an important part of working in a team.

When a coding standard is not followed, what happens to that code? Must it be fixed immediately? How does that effect its testing, retesting, or release time lines? Some consider this code to be technical debt. That is a difficult label to apply to code if the violations are simply style related.

Since coding standards should be trivial to follow they should break your build and get fixed. If you or team members have a problem with that: Have a discussion, make a decision, be done with it. What is the problem with the label technical debt? Violation of coding standards make it harder to read that code. That is the interest rate you pay for that debt until you pay it back. Fits perfectly. Of course how large that debt is when a single { is misplaced is a different question. But then again, paying that back should be as simple as opening the file and pressing a shortcut.

Proper enforcement of coding standards can consume an unreasonable amount of time.
The decision to enforce coding standards and its consequences must be embraced at all levels within a company. Most companies struggle to embrace doing something twice.

Why is enforcing rules “doing something twice”? Don’t understand that. For the first sentence. Of course you can come up with coding standards that are hard to enforce. Just don’t. Use standards that play well with your tool setting. Automate it. And think again if your coding standard has to be company wide. This works well for small companies, but results in coding standards 1000 pages thick and completely useless. I have seen those. That shouldn’t keep you from having coding standards for your team.

Zac continues to recommend code reviews. A good thing! But not a replacement for coding standards.

You absolutely should have coding standards in any team consisting of two or more developers. Part of deciding on the standards to use should be the way to enforce them and this should be largely automatic.

Even more important than coding standards is a team standard on how to make decisions. If that standard fails in the trivial case of coming up with coding standards you have a serious problem.

And don’t go for compromises when it comes to coding standards (by Geek&Poke)
coding standard compromise by Geek & Poke

 

Published at DZone with permission of Jens Schauder, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Dapeng Liu replied on Tue, 2013/02/12 - 5:32am

programming needs discipline, coding standard is the most basic ones 

Steven Goldsmith replied on Tue, 2013/02/12 - 12:01pm

Pretty thoughtful replies to Zac. The only thing I'd add is that it doesn't take a team effort to use coding standards. You should use them even if you are the lone wolf coder. It will make it easier for you to integrate into teams that have standards since you already "think" this way,

Serge Bureau replied on Tue, 2013/02/12 - 3:14pm

 Languages comes with guideline, adding coding standard brings only noise.

Do not slow down your programmers, let them code more freely and use a beautifier to bring it to your style.

Coding is not a robotic exercise, I see too often languages features being disallowed, this is non sense.

Some consistency is nice, but I hate religions.

Steven Goldsmith replied on Tue, 2013/02/12 - 3:33pm in response to: Serge Bureau

Yea, free for all is the way to go. Coding standards are more than formatting and has nothing to do with religions. It sounds like perhaps you failed a CI build recently :) Coding standards != creativity.

Serge Bureau replied on Tue, 2013/02/12 - 6:20pm in response to: Steven Goldsmith

I can see by your answer, that you have very high standard.

Mark Unknown replied on Thu, 2013/02/14 - 11:53pm

Good response. The best way to learn standards are good... try to fix code that doesn't follow any, well not any good ones.  And if you don't learn from that ... . 

Too many people fail to remember most software effort is in maintenance.

Serge Bureau replied on Fri, 2013/02/15 - 7:14am in response to: Mark Unknown

There is a big difference between having no standard and being forced to follow a specific one, that I am against. For syntax you have beautifiers, a good percentage of the rest is library calls.

Plus because of the nature of the projects, the structure of the packaging´is pretty much given to you, so the differences left are not a high percentage and should not be much concern at all.

Chris Treber replied on Sat, 2013/02/23 - 5:35am

Thank you for saving me from writing a reply to the article. If coding guidelines curb your style, you're not creative, you have an issue.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.