C# Coding Standards and Practices

Welcome to my first article as a contributing editor for C#. For my first of many weekly articles I'm going to cover coding standards and practices, a topic that is often overlooked.

Define and Publish your C# Coding Standards and Practices

C# coding standards and practices can quickly become hotly debated among developers when they are discussed. I've seen folks go into such a conversation thinking it is a waste of time and getting hotly involved in debate over a particular convention. It is an area where there is rarely a right or wrong, but plenty of opinion. The best advice that I can offer is to make sure you define and document the practices. No matter what they are, identifying what you want to follow is imperative. Once defined, they must be made accessible and communicated to others. This is a great use for a wiki so that others within the organization can contribute.

The following list contains common areas that should be defined within your standards and practices:

  • Source code structure, layout, and formatting
  • Variable naming standards and conventions
  • Rules around commenting your code
  • Exception handling pattern and process
  • Version control and compilation rules
  • Expectations around flow control
  • Programming patterns that should be applied (or avoided)
  • Database related practices

You should document your rules in a clear and concise manner. It is valuable to include a concise coding example that supports the rule, as well as an example that violates a particular rule.

You may also find it useful to break your standards into a series of documents as not all standards and practices apply to all languages. You will likely have some standards and practices specific to the environment if you are an Azure developer, ASP.net developer, C# developer, Visual Basic developer, Windows Mobile developer, WCF developer, ASP.net MVC, Silverlight developer, or programming in C or doing C++ programming. For example, I have standards and practices around use of Session State and View State for ASP.NET applications that would not apply to other types of development.

Enforce Coding Standards and Practices

Coding standards and practices lose their value if not everyone on the team is following them. I've been involved with organizations that do formal code reviews that involve going before a review board of sorts. Those meetings can be very time consuming and tedious. I've also seen a high number of organizations that ignore them altogether as there may be a single developer assigned to a particular project and they are left to their own devices. I employ a mixture of manual as well as automated code reviews. There are great tools like FxCop, which integrates with Visual Studio, and is included in certain versions of Visual Studio. It has rules that can be customized and tailored to your standards. It quickly analyzes your code and reports on findings. This is a great starting point for analyzing code and looking for hotspots. It is also valuable in Visual Studio Team System to use code check-in rules to force developers to run tools on their own code prior to check-in.

Example Standards

The following links point to a couple of sources where you can find some examples of coding standards and practices that I consider to be worthwhile as a starting point:

About the Author:

Mark Strawmyer is a Senior Architect of .NET applications for large and mid-size organizations. Mark is a technology leader with Crowe Horwath LLP in Indianapolis, Indiana. He specializes in architecture, design and development of Microsoft-based solutions. Mark was honored to be named a Microsoft MVP for application development with C# again. You can reach Mark through http://markstrawmyer.com.



About the Author

Mark Strawmyer

Mark Strawmyer is a Senior Architect of .NET applications for large and mid-size organizations. He specializes in architecture, design and development of Microsoft-based solutions. Mark was honored to be named a Microsoft MVP for application development with C# for the fifth year in a row. You can reach Mark at mark.strawmyer@crowehorwath.com.

Related Articles

Comments

  • Only 35 - Erectile Dysfunction Patients, Is This a Age? - Know the Numbers

    Posted by alueffifielm on 06/21/2013 04:09pm

    For how long Does It Take Cure Erectile Dysfunction Problem? The sample pack was of a 25 mg strength while the prescription was for a 50 mg strength [url=http://rxhealth.pw ] viagra cheap price [/url] see a lot more Erectile Dysfunction Causes and Symptoms that Every Man Should Know

    Reply
  • http://www.nikeairmaxwr.com/ duqfcn

    Posted by http://www.nikeairmaxwr.com/ Suttonvkq on 03/30/2013 12:19am

    ray ban new wayfarer,Had buried the chest, afraid to look Limei. This Limei, shook his head a little bit funny. Then began to walk toward the other land areas. I received the captain ground. In just a few hours, already gave birth to a lot of things. This time has Xiaowei and and Sun Zhong reached already enter the big cave of silken soon. But soon ray ban sunglasses trouble. Because the already fluent cave not know why he was blocked by thick ice ray ban sunglasses sale difficult to continue to move forward. Or Viagra to get you the fire to melt these ice? Sun, Chung reached his hand touched the cold ice. Thin and looked a lot after then turned his head toward Zeng Xiaowei asked, because he knew had Xiaowei is a master of control fire. This ice should be something that he was responsible, but had Xiaowei hear was immediately scolded, pointing to his nose off. I could not know inside ray ban prescription glasses,raybansunglassesouty.com/" title="ray ban wayfarers"ray ban wayfarers arrival?

    Reply
  • cheap oakleys sunglasses

    Posted by ngliliImpumpnnp on 03/29/2013 10:14am

    http://qualityguccisunglass.webs.com - oakley sunglasses cheap oakley sunglasses discount http://sunglasswholesaleofgucci.webs.com - cheap oakleys for sale cheap sunglasses http://onlineguciisunglass.webs.com - wayfarer sunglasses cheap replica sunglasses http://akeoakleysunglasses.webs.com - fake ray ban sunglasses oakleys for cheap http://wholesalesunglassescool.webs.com - wholesale designer sunglasses replica oakleys

    Reply
  • cheap wayfarer sunglasses

    Posted by rgliliImpumptsw on 03/29/2013 10:12am

    http://discountsunglassesfinewebs.com - discount ray ban fake ray ban wayfarer http://olesalesunglassesgood.webs.com - wholesale sunglasses sunglasses cheap http://guccisunglassescheap.webs.com - cheap ray ban sunglasses wholesale designer sunglasses http://sunglassdicountsaleu.webs.com - cheap oakleys sunglasses discount sunglasses http://fakeGucciwayfarer.webs.com - fake ray ban wayfarer sunglasses wholesale

    Reply
  • http://www.oakleysunglassesoutc.com/ twmegr

    Posted by http://www.oakleysunglassesoutc.com/ Mandyxed on 03/29/2013 05:44am

    K organs was founded five years, Tan Yan founded this institution in response to the need of the Sino-Russian war intelligence organs of the trunk strength is basically concentrated in the Northeast, branch independent intelligence agencies outside the party headquarters, even the south of the Yangtze River are no crossed to sources widely in Shanghai, Hankou and Guangzhou each set up a covert agent Office. The conflicting interests of the various aspects of the Republic of embryonic very serious. Tan Yan is also a virtue of absolute military power in the hands of all the contradiction between pressure at the bottom ghd sale seems, if not in the hands of absolute military power, under a variety of organizations have armed forces will not be more than the history of that fall apart Republic of much better. Tan Yan did not intend to authoritarian rule in China ghd hair straightener not so high power to change the backwardness of China, just to smooth Exhibition, cheap ghd had power, especially military power firmly in his hands, and The special nature of intelligence work ghd australia groups in an invincible position in the strange political struggle play a very crucial role in land, in addition to the real intelligence organization, K organs is dedicated ghd hair straightener a service intelligence organizations, the cost of their activities was not out of the national finances.

    Reply
  • fake ray ban

    Posted by bgliliImpumpjzu on 03/28/2013 10:22pm

    http://akeoakleysunglasses.webs.com - fake oakleys cheap ray ban http://discountsunglasseshoo.webs.com - discount ray ban sunglasses cheap fake oakleys http://discountsunglassessale.webs.com - oakley sunglasses discount discount sunglasses http://guccicheapsunglass.webs.com - cheap ray ban,,,, fake ray ban wayfarer http://cheapsunglassesshop.webs.com - cheap oakley fake ray ban

    Reply
  • http://www.tomsoutletw.com/ xmrqbi

    Posted by http://www.tomsoutletw.com/ Mandyqnf on 03/28/2013 10:49am

    ray ban wayfarer,Also did not wait for those who are the Molten Boulder Zayun past monster wake up, followed by a temperature gas is emitted empty under the walls, the scorching heat wave monster lives gradually goes by. Embraced each other with the Druids move volcanic explosion Necro shaman cast out, want the same red The same curse spells Falling Damage, due to the walls below has gathered dense monsters to attack the walls, so Damage Falling a sprinkle is a large one, simply do not see. Curse Necro sorcerer ray ban at this time to play the most, the walls below also started out many of the bodies, so the Deathly Hallows sorcerer strong skill Corpse Explosion also began to have its uses, often a Corpse Explosion , the monster be affected is a large.ray ban wayfarer sizes,raybansunglassesouty.ray ban clubmaster,com/" title="cheap ray ban sunglasses"cheap ray ban sunglasses, Assassin trap, Amazon's multiple arrows, paladin auras, Barbarian cry, colors Guanghua constantly flashed between career with monsters.

    Reply
  • cheap ugg boots qKpy bHnj

    Posted by Suttonbla on 03/09/2013 08:06pm

    tory burch shoes sale emhlhqov Cheap Tory Burch shoes ycexudch Tory Burch outlet online rnvjdvdd discount Tory Burch shoes xzmnxjmo Tory Burch outlet sale zsimyttn Tory Burch Boots kveiyusp Tory Burch Flats mexovmks Tory Burch Flip Flops npytztga Tory Burch Handbags dufehvrv Tory Burch Heels vpfnvftt Tory Burch Reva Flats dyrrvbsm Tory Burch Sandals wnerthaf Tory Burch Wallets sspiwdpp Tory Burch Wedges cffnbmlc

    Reply
  • ugg boots meyujv http://www.cheapfashionshoesas.com/

    Posted by Suttonasm on 01/27/2013 06:14am

    9ePaj nike online store iEgq Michael Kors outlet lQhz ugg boots 5uMwh beats by dre 4tBdv Cheap nfl jerseys 0hGqk uggs norge 3tEaj burberry outlet 0qByw longchamp sale 5pQec nike shoes online 1sVoy ugg boots uk 6aFmu dr dre headphones 2zUzz ugg espa?a 3xJqm GHD Australia 7iCkd 3xWet

    Reply
  • ugg boots ixyxfc http://www.cheapfashionshoesas.com/

    Posted by Mandyixx on 01/27/2013 01:35am

    6oEhx cheap nike shoes iNaf Michael Kors outlet iFwp ugg boots 9nDfn monster beats 5rMhj Cheap nfl jerseys 5zXhs ugg norge 5rRpw burberry outlet 7nAbx longchamp 1zFlk cheap nike free run 5iLgj cheap ugg boots 6pTol monster beats 5dDlg ugg 9yKmp GHD Australia 1rVyp 4fLfw

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Wednesday, September 24, 2014 8:00 AM - 9:00 AM PDT According to a recent Forrester Research report, many companies are choosing low-code platforms over traditional programming platforms, due to the speed with which low-code apps can be assembled and tested. With customer-facing applications on the rise, traditional programming platforms simply can't keep up with the "short schedules and rapid change cycles" required to develop these applications. Check out this upcoming webinar and join Clay Richardson from …

  • Not long ago, security was viewed as one of the biggest obstacles to widespread adoption of cloud-based deployments for enterprise software solutions. However, the combination of advancing technology and an increasing variety of threats that companies must guard against is rapidly turning the tide. Cloud vendors typically offer a much higher level of data center and virtual system security than most organizations can or will build out on their own. Read this white paper to learn the five ways that cloud …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds