473,802 Members | 2,015 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 2406
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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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
2225
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 unsigned 8 byte integers. Naturally this broke my code which uses fseek(), and can only offset by longs, which on the target OS is a 4 byte integer. There are ways around this using OS calls, but as far as I can tell the C99 standard offers no...
5
1219
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, usually clicking on a top-level menu item. I am using Infragistics 2004 Vol 1 for menus and docking regions. Can anyone suggest ways of tracking the cause down? The main MDI form is started with Application.Run(New MyForm), which is inside a...
6
1261
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 a couple of years, but this is my first shot at making a GUI so I'd very much appreciate some ideas from you people to get me going in the right direction. Despite my GUI n00b-ness I need to get it good and usable with an intuitive look and feel.
126
6756
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: http://www.cse.wustl.edu/~schmidt/ACE.html the same way that the STL (and subsequently BOOST) have been subsumed? Since it already runs on zillions of platforms, they have obviously worked most of the kinks out of the generalized threading and processes idea (along with many...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.