Posted By: Another_Darren | Apr 19th, 2006 @ 8:18 AM
page 1 of 1
Comments: 14 | Views: 8467
Another_Darren
Another_Darren
... than you can shake a stick at
I'm looking for a published document for MS coding standards around the C#/ASP langauage.

We are taking C#/ASP on at work and we want to adopt the standard coding style that MS and all it's tools use.  If we could get this as a doc we can include it in our training pack for new/retrained developers as a reference tool.

Obviously the document would have to be public domin, creative commons, etc to allow us to use it internally.

Thanks.
footballism wrote:
I think you are look for this

Sheva


Good find.

For a hard-copy reference, check out

 
Dr Herbie
Dr Herbie
Horses for courses
I would second the link to FXCop -- it means that you can automatically check your code for conformance, rather than having to use any tedious manual reviews.

As a side remark, maybe you should get your department to invest in a copy of Code Complete is you don't already have one. It's full of useful details about coding styles and which ones seem to work best (as well as a multitude of other useful stuff).

Herbie

lorad
lorad
Lorad
The coding standards linker are pretty good. The only one we differ on where I am the maker of standards is that members are prefixed by _ (underscore) here.
 
Our reasoning.....
 
int _foo;
public int Foo { get { return _foo; } }
 
It is easy to see what people are using, we have had a number of bugs where someone did Foo = x; when they meant foo = x; when we did not use underscores. While these are bugs and are caught eventually, it is always nice to make it harder to code problems. (this.foo would not help in this case)

Plus it keeps it consistent for VB and C# since VB is case insensitive it is impossible to have accessors named the same as the internal variables.

While we don't do much VB.NET work, it is nice to keep consistent coding standards across languages when at all possible.
Another_Darren wrote:

We are taking C#/ASP on at work ...


I would STRONGLY encourage to arrange so that everyone taking on C# at work would have to watch atleast couple of these.

http://msdn.microsoft.com/netframework/programming/classlibraries/


Unless of course the intention is to make it someday into theDailyWTF. Big Smile 

I don't agree with:

Brad Adams wrote:
Classes member should be alphabetized, and grouped into sections (Fields, Constructors, Properties, Events, Methods, Private interface implementations, Nested types)


public class FooClass : IFoo
{
    // delegates
    public delegate void OnSomethingEventHandler();
    ...
    // events
    public event OnSomethingEventHandler OnSomething;
    ...
 
    // fields
    private int foo;
    ...

    // properties
    public int Foo
    {
        get { return foo; }
        set { foo = value; }
    }
    
    // constructors
    public FooClass()  {}
    public FooClass(int something) {}

    // unmanaged code
    [DllImport ...] ...
    
    // methods
    private void Lala() {}
    public void La() {}
    ...

    // interface impl.
    private void IFoo.sddf() {}    
    ...

    // nested types: class
    internal class XYZ {}
    ...
  
    // nested types: structs
    public struct XZ {}
    ...

    // nested types: enums
    public enum : int { ... }     
}

So how is your coding style? How do you organize your project (in multiple projects or?), how do you name controls?

Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...
lorad wrote:
The coding standards linker are pretty good. The only one we differ on where I am the maker of standards is that members are prefixed by _ (underscore) here.

I agree. Differing identifiers only by case is a bad idea, imho.
footballism
footballism
Another Paradigm Shift!
I think you are looking for this

Sheva
PerfectPhase
PerfectPhase
"This is not war, this is pest control!" - Dalek to Cyberman
W3bbo
W3bbo
The Master of Baiters
This thread is over 2 years old.
Dr Herbie
Dr Herbie
Horses for courses
But it is still relevant ...

If you like things if book format:  Framework Design Guidelines is quite good, too!

Herbie
page 1 of 1
Comments: 14 | Views: 8467
Microsoft Communities