473,379 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

coding standards - sections in class files

Is there a standard for where to put the different
categories of code in a class file? For example, after the
class declaration, normally I put class variables, then
constuctor, then private methods, public methods, then
properties etc. Is there a standard for this order?

Anyone know of a good template in CodeSmith or in the MS
VS template language that seperates the different pieces
of code?

Thanks!

Jon Paugh
Jul 21 '05 #1
5 1510
Jon:

That's one of the cool features of VS.NET, you can come up with what works
best for you and then enforce it with Regions. #Region SomeRegion

ABunchOfMethods

#End Region
"Jon Paugh" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Is there a standard for where to put the different
categories of code in a class file? For example, after the
class declaration, normally I put class variables, then
constuctor, then private methods, public methods, then
properties etc. Is there a standard for this order?

Anyone know of a good template in CodeSmith or in the MS
VS template language that seperates the different pieces
of code?

Thanks!

Jon Paugh

Jul 21 '05 #2
The more I use regions, the more specific I find myself getting. In a
recently-coded class, for instance, I defined regions for:

Constructors
Constants and data (you could divide these into static and instance regions)
Static methods, if any, including the static constructor if supplied
Base class overrides
Public properties
Public methods
Protected properties
Protected methods
Private members (usually methods, and very rarely private properties)
OnXxxxxx methods (for controls, which have a panoply of protected methods
like OnClick, OnMouseDown, etc.)
interface implementations (e.g., IEnumerable, IDisposable, etc.) with one
region for each interface
Event handlers

I think the order of your regions is up to you, but it seems to make sense,
for me anyway, to put them in more or less the order I listed them above:
constructors, implementation data, static members, base class instance
overrides, and then public, protected, and private members in order of
visibility, followed at the end by the bookkeeping sections (the
interfaces), and finally the event handlers (at the end because that's where
the IDE creates them when you go through the Events user interface).

If the IDE had a key combination or context menu item for "collapse all
regions", I'd be ecstatic but I haven't found such a thing yet.

Best regards,
Tom Dacon
Dacon Software Consulting
"Jon Paugh" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Is there a standard for where to put the different
categories of code in a class file? For example, after the
class declaration, normally I put class variables, then
constuctor, then private methods, public methods, then
properties etc. Is there a standard for this order?

Anyone know of a good template in CodeSmith or in the MS
VS template language that seperates the different pieces
of code?

Thanks!

Jon Paugh

Jul 21 '05 #3
Try CTRL+M, CTR+O

Granted, its TWO key presses, but once you get used to it, it works just
fine. And you can probably re-map it.

A good read for other VS.NET tips and shortcut keys:
http://www.sellsbrothers.com/spout/d...vs.netfunfacts

-Josh

Tom Dacon wrote:
If the IDE had a key combination or context menu item for "collapse all
regions", I'd be ecstatic but I haven't found such a thing yet.

Jul 21 '05 #4
Gracias.

Tom Dacon

"Joshua Flanagan" <jo**@msnews.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Try CTRL+M, CTR+O

Granted, its TWO key presses, but once you get used to it, it works just
fine. And you can probably re-map it.

A good read for other VS.NET tips and shortcut keys:
http://www.sellsbrothers.com/spout/d...vs.netfunfacts
-Josh

Tom Dacon wrote:
If the IDE had a key combination or context menu item for "collapse all
regions", I'd be ecstatic but I haven't found such a thing yet.

Jul 21 '05 #5
Sure, but if there were a standard we would use it. And I
do see some ad-hoc sorts of standards at least starting to
develop based on seeing some consistantly named regions in
unaffiliated authors code.

-----Original Message-----
Jon:

That's one of the cool features of VS.NET, you can come up with what worksbest for you and then enforce it with Regions. #Region SomeRegion
ABunchOfMethods

#End Region
"Jon Paugh" <an*******@discussions.microsoft.com> wrote in messagenews:09****************************@phx.gbl...
Is there a standard for where to put the different
categories of code in a class file? For example, after the class declaration, normally I put class variables, then
constuctor, then private methods, public methods, then
properties etc. Is there a standard for this order?

Anyone know of a good template in CodeSmith or in the MS
VS template language that seperates the different pieces
of code?

Thanks!

Jon Paugh

.

Jul 21 '05 #6

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

Similar topics

3
by: ganesan | last post by:
Hi Guys, Could any one knows the best coding standards styles(with variable declarations for c#) . and if any links or site with the best coding standards for .NET send me those links regards...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
5
by: Jon Paugh | last post by:
Is there a standard for where to put the different categories of code in a class file? For example, after the class declaration, normally I put class variables, then constuctor, then private...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
3
by: editormt | last post by:
A recent poll asked if programming standards are used by development organisations... and if they are controlled. None: 20% Yes, but without control: 49% Yes, with control: 31% Participants:...
1
by: pat | last post by:
Abraxas Software Understanding YOUR GOALS & Using CodeCheck Implementing Corporate Source Code Guidelines C/C++ Source Code GuideLine Automation The goals of CodeCheck are: 1 To create a...
0
by: pat | last post by:
CodeCheck Coding Standard's Support As a free service to our customers we offer support in developing "rule-files" for automating corporate coding standards. If you have a coding standard that...
19
by: auratius | last post by:
http://www.auratius.co.za/CSharpCodingStandards.html Complete CSharp Coding Standards 1. Naming Conventions and Styles 2. Coding Practices 3. Project Settings and Project Structure 4....
4
by: gentsquash | last post by:
On some of my course pages, I quote (with attribution) small sections of Wikipedia and the like. E.g, the top of http://en.wiktionary.org/wiki/entropy has "entropia" in Greek font, ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.