Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Probably, the basic situation is familiar to everyone. You have agreed on certain coding standards in your team and now it is time to make sure that everybody follows them.

Some do it via heavy paired programming, others maintain a list of coding standards and do a manual review. Others even use the static code analysis tool from Visual Studio to make sure that coding standards are enforced.

What are your best practices to ensure coding standards? Which tools do you use - are there some essential tools every dev should know? How do you integrate the standardisation of your code in your development tools?

Thank you!


share|improve this question

migrated from Mar 3 '12 at 3:37

This question came from our site for professional and enthusiast programmers.

"this is some kind of brain storming" - meaning it is off topic. Brain storming/opinions/polls are not suitable to the StackExchange Q&A format. Please read the FAQ. – Oded Mar 2 '12 at 16:57

StyleCop (now also StyleCop for Resharper) is commonly used to enforce coding style rules within C# code bases.

It can be integrated into your CI build and cause build failures if any violations have been introduced.

share|improve this answer

First, make sure you have a proper build server that continously builds your code. TFS or Jenkins/Hudson+Msbuild are good options. On this build server you of course run tests, and you can also run static code analysis as well as syntax checkers.

I recommend Using FxCop or Gendarme for static code analysis. Both can be used side by side.

One important key to success: don't deploy them with a massive ruleset and expect it to work well. You will have millions of warnings and noone will care.

Rules of thumb are:

  • Always have zero warnings. Reduce the set of checks initially if you have to, then add some new checks every sprint and fix those. Make sure every check performed has actual value to you and is consistent with your standards.

  • If you have domain specific rules you need to adhere to, don't be afraid to implement your own rules.

For syntax check, use StyleCop or StyleCop for Resharper if you are using Resharper (which I highly recommend as well).

share|improve this answer

StyleCop and FxCop are my light weight tools that remind code styles to my developers. Resharper is also good one, but it makes VS very slow.

I recommend FxCop because of its' rich rules library, with great documentation, classifications, examples and many other features.

There's also StyleCop Fixer extension for visual studio available, helps to fix ordinary mistakes.

Code Metrics is also affected sometimes by code styles. You can monitor maintainability of codes with this tool.

share|improve this answer

I would like to emphasise getting the automatic code analysis already mentioned (FxCop, StyleCopy, CI builds etc) working first, in preference to manual reviews. The automatic checks will pick up far more things than a manual review is likely to, and is normally much more rigorous, consistent and is self documenting. Manual reviews can be good for more high level design decisions etc, but in my experience they can be very subjective and haphazard.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.