473,406 Members | 2,390 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,406 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 1513
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, ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.