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?"

8 of 82 comments (clear)

  1. Google sez... by Hard_Code · · Score: 2, Informative
    Following the Microsoft recommendations in the Framework SDK might be a
    good idea - they seem pretty well thought out, and the code is going to
    look and feel familiar to other .NET programmers.

    > -----Original Message-----
    > Sent: Monday, July 09, 2001 7:01 PM
    > Subject: [Mono-list] C# coding standards for Mono
    >
    > Hey kids,
    >
    > Has anybody taken a stab at a C# coding standard for Mono classes?
    I'm
    > thinking something along the lines of Sun's Java Coding Conventions
    > (http://java.sun.com/docs/codeconv/html/CodeConvTO C.doc.html)
    >
    --

    It's 10 PM. Do you know if you're un-American?
  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. 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

  5. Maybe it's just me, but ... by Anonymous Coward · · Score: 1, Informative

    Having an IT guy come up with coding standards is like asking the janitor to design an operating system.

    (The fact that he's consulting with Slashdot regarding aspects of his job is kind of a hint.)

  6. 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.



  7. Re:Use the IDE's beautify by chrisseaton · · Score: 2, Informative

    Bullshit! That is nothing like how VS formats code. I just copied and pasted and this is how it formatted:

    namespace Foo
    {
    public class Bar
    {
    void Bar()
    {
    if (foo)
    {
    bar(0);
    }
    else
    {
    bar(1);
    }
    }
    }
    }

  8. Re:VS.NET by diesel_jackass · · Score: 2, Informative

    I was in your shoes when I was using UltraEdit and the free .NET SDK for development. I had all kinds of macros set up to autogenerate a separate xml file where my comments would be extracted from the code and placed into, while placing the rest of the 40 or so cs files into a dll and running it, etc. I thought that the color coding was help enough with programming. I'd just assumed that VS.Net was just bloat-ware like every other MS dev. env. that I've used in the past.

    However, unless you have the entire .Net built-in class libraries in your brain and can compile code with warnings in your head on the fly, VS.Net will greatly speed up the development process. (It's much easier to hit ".", "(", or CTRL+SPACE, than to google MSDN for what I'm looking for.) Aside from all the other features already listed, its integration with VSS is pretty seamless.

    You really have to use it for a day to realize it's potential. All the MS marketing fluff sites don't do it any justice. Ours at work was included with individual MSDN Universal subscriptions for all of our developers. We all got to upgrade from NT and whatever development tools we were using before (VS6.0, HomeSite, UltraEdit, notepad, vim).