C# Coding Standards

I recently started documenting my own C# Coding Standards and best practices.   The current document is very much a work-in-progress, but I am making it freely available for download.  Please reply with any comments, questions, or feedback on this blog entry.

Click Here, to download the PDF.
[ Updated to v1.13a]

 

Why yet another coding standard document?

There have been numerous attempts at document C# Coding Standards since the language was released, but I usually have disagreements with many of the guidelines and rules they contain.  This is my attempt to start from scratch and write a new standards document that represents my preferred style.  I'm sure that many of you will have just as many disagreements, but I am looking forward to the debate. :)

Enjoy!

 

6 Comments

  • For the most part I agree with most of your standards. There are two things I noticed that I do differently. I use all uppercase for constant names and I don't use "_" for member variables instead I always prefix with the keyword "this". I don't know if you care but I also noticed you used both the words function and method, I find myself doing this too but when I realize it I switch it to method.



    HTH

    Wes

  • Thanks for the feedback...



    I think you hit on all of the areas that I see the most debate.



    I am still undecided on using uppercase names for Constants. I have to admit that I occasionally switch between Uppercase and treating them like member variables depending on the project.



    I fixed the references to function vs. method. Thanks for the catch!



    I just posted an updated version (v1.01) with various additions, changes, and the correction above.



    Let me know what you think...

  • Why do you recommend creating strongly typed datasets?

  • I had a brief look, seems mostly ok.



    How about a creating a set of rules for fxCop, so we can see what the rules haev to say about some code.

  • public Collection<Order> Orders

    {

    get

    {

    ...

    }

    }



    public Collection<Status> XX

    {

    get

    {

    ...

    }

    }



    So by your coding standards what would you name property XX?

  • I've always used "States" as the plural of status. It may or may not be dictionary-proper, but it gets the point across. If you really want to eliminate the confusion, you can then change the single "Status" to "State" since most times they are functionally equivalent.

Comments have been disabled for this content.