473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suggestions for standard regions

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?

Nov 16 '05 #1
4 2396
Hi...

You may want to check for C# Coding Standard via Google or AllTheWeb.com.
Many of the published standards address this question.

John Puopolo

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

Nov 16 '05 #2
Yes, I have already found some good references from
Phillips, IDesign (Juval), Lance Hunt and MSDN. However,
none of them, unless I've missed it, tackle the issue of
what order to do things in. Of course, I can make my own
up, but I would have thought this would have been dealt
with. Perhaps it's not as interesting as brace placement or
the use of tabs which both seem to be hot topics of debate ;)

-----Original Message-----
Hi...

You may want to check for C# Coding Standard via Google or AllTheWeb.com.Many of the published standards address this question.

John Puopolo

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

.

Nov 16 '05 #3
"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
Nov 16 '05 #4
Here's the order of regions that I use:
fields
events
properties
constructors
instance methods
static methods

This is not a complete list, and I agree with Michael S mostly. There
is no way I could come up with rules for this and stick with them. The
above is what I _tend_ to do, but there are times when I create more
specialized regions to enhance maintainability. I also alphabatize
members within regions.

Best regards,
Jeffrey Palermo
Blog: http://www.jeffreypalermo.com

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2210
by: David Mathog | last post by:
I recently ran into a problem where a data file downloaded from another site contained more than 4Gb of data and so the index file to items within that data went from unsigned 4 byte integers to...
5
1203
by: Charles Law | last post by:
I have a VB.NET MDI application that terminates for no reason. Sometimes it will run for ages, and sometimes it terminates after a few seconds. It always seems to occur following some user action,...
6
1245
by: Joel Hedlund | last post by:
Hi! I've been thinking about writing a good multiple sequence alignment (MSA) viewer in python. Sort of like ClustalX, only with better zoom and pan tools. I've been using python in my work for...
126
6609
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.