"Simon" <an*******@discussions.microsoft.com> wrote in message
news:12****************************@phx.gbl...
Just starting on C# and would like to know what suggestions
there are for the order in which declarations, event
handlers, properties, private code, nested classes, etc,
etc appear in your files. What impact do access modifiers
have on the order? Also, does anyone use standardised
region names?
Over the years I've tried diffrent approaches and tried to have well defined
rules for all my classes.
Rules like starting withall public methods and public events, then the
protected and finally the proivate parts.
However, I've given up all such efforts.
I have found that no rules is best practice. But what I do try to do is
imagining that I am a maintainer who have never seen my code before. From
that I try to place the most important methods in the order they are
typically being called. If a public method calls three private methods, I
try to keep the private once close to the public caller.
Simple and obvious methods I put at the bottom of the source file.
Oh, and I tend to make sure that an class member variables are at the top of
the class.
- Michael S