Slashdot Mirror


Coding Standards for C#?

infinite9 asks: "I've been given the task of writing the coding standards for my corporation. I've been in IT for 12 years, so many things are obvious. Recently though, my employer has standardized on C# and .NET, and since I'm new to the technology (isn't everyone?) I'm not sure what to include. I've included a paragraph about signing assemblies with a standard key pair as well as a few other odds and ends. Apart from the obvious statements that apply to any language like good comments, good variable names, and maintainable code, can anyone suggest other C#/.NET related things that I should include?"

9 of 82 comments (clear)

  1. Use the IDE's beautify by buro9 · · Score: 3, Insightful

    Don't attempt to come up with any of your own formatting rules (as much as it's tempting to make your code look like the rest of your code)... having a standard formatting implemented by the IDE results in much cleaner formatting and will ensure that the people you hire will understand the code that much sooner.

  2. C# Coding Standards by cymantic · · Score: 4, Informative

    To work out some standards use what you know from Java, Python or any other language with a C based syntax.

    The guys at ICSharpCode (http://www.icsharpcode.net/TechNotes/) have some nice documents on coding styles/standards for coding for #Develop (you don't have to follow them when coding using #Develop)

    Also have a look at something like FX Cop from MS (http://www.gotdotnet.com/team/libraries) to help enforce coding standards.

    t

  3. Reasonable, my twopennyworth by Burb · · Score: 3, Informative
    This is pretty sensible advice. Most C# shops I've worked in stick to the standard MS coding conventions.

    I would also stress: use the inline documentation stuff a log (/// comments). Use NDOC to generate documents from the XML output. Make use of the using() {} statement to encourage early resource disposal.

    --

  4. Wait until you see what's on the horizon! by wonkamaster · · Score: 3, Funny

    It doesn't really matter what coding standards you implement, as long as something consistent is used. And that doesn't really matter much either.

    Microsoft will probably innovate a new language syntax soon, my guess would be C##. It will undoubtedly be more scalable, secure, robust and less prone to errors. And it'll automatically be included in the latest version of Windows, but not be compatible with previous versions due to architecture limitations.

    Personally, I'm holding out for that version. I'm going to push my company to standardize on that version. Because it just makes good business sense.

    We need a moderation for Sarcastic!

  5. MS design guidelines by Jussi+K.+Kojootti · · Score: 4, Informative
    Yep, They're not bad: Design Guidelines for Class Library Developers.

    Maybe you'll find this useful: White paper on resource management in components written for the Common Language Runtime (CLR).

    -jk

  6. New technology? by n1k0 · · Score: 4, Funny

    > and since I'm new to the technology (isn't everyone?)

    Used Java? ;-)

  7. Two non-obvious things I'd suggest by Sevn · · Score: 4, Insightful

    Make sure you recommend CVS, or some other type
    of versioning system to save hell down the road.

    Enforce under penalty of death or termination of
    employment that DOCUMENTATION IS PART OF DEVELOPMENT.
    I've had many a contract where I've basically just
    had to say "screw it" and redo a rats nest of
    undocumentated code because of zero documentation.

    --
    For every annoying gentoo user, are three even more annoying anti-gentoo crybabies. Take Yosh from #Gimp for example.
  8. In addition to the coding standards pointed by... by Utopia · · Score: 3, Informative


    ....several other readers. Take a look at FxCop.
    It will help you check your code for conformance to design guidelines and point out possible usage errors, localization issues, security problems, and possible performance improvements.



  9. Poor guy. by pmz · · Score: 3, Insightful

    Recently though, my employer has standardized on C# and .NET, and since I'm new to the technology (isn't everyone?)

    I'm suprised your company would take such a high-risk action. "Standardizing" on something so new and untested is, IMO, irresponsible.

    Adopting .NET now is like adopting J2EE when it was at version 1.0 or 1.1. The details of the APIs aren't hammered out, yet, so a lot of code your company creates will be "legacy" very quickly--probably within one year. If you don't believe me, ask anyone who jumped onto the JSP and Java Servlet bandwagon when they first came out (before tag libraries, etc.).