PC Review


Reply
Thread Tools Rate Thread

coding standards - sections in class files

 
 
Jon Paugh
Guest
Posts: n/a
 
      19th Dec 2003
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
 
Reply With Quote
 
 
 
 
William Ryan
Guest
Posts: n/a
 
      20th Dec 2003
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" <(E-Mail Removed)> wrote in message
news:093001c3c67d$2bb9e2c0$(E-Mail Removed)...
> 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



 
Reply With Quote
 
Tom Dacon
Guest
Posts: n/a
 
      20th Dec 2003
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" <(E-Mail Removed)> wrote in message
news:093001c3c67d$2bb9e2c0$(E-Mail Removed)...
> 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



 
Reply With Quote
 
Joshua Flanagan
Guest
Posts: n/a
 
      20th Dec 2003
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.

 
Reply With Quote
 
Tom Dacon
Guest
Posts: n/a
 
      20th Dec 2003
Gracias.

Tom Dacon

"Joshua Flanagan" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Jon Paugh
Guest
Posts: n/a
 
      22nd Dec 2003
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 works
>best for you and then enforce it with Regions. #Region

SomeRegion
>
>ABunchOfMethods
>
>#End Region
>
>
>"Jon Paugh" <(E-Mail Removed)> wrote

in message
>news:093001c3c67d$2bb9e2c0$(E-Mail Removed)...
>> 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

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding Standards davidsamith@gmail.com Microsoft Excel Programming 0 31st Aug 2007 07:06 AM
Coding Standards UJ Microsoft C# .NET 11 15th Feb 2006 08:37 PM
ASP.NET Coding Standards =?Utf-8?B?UHJhdmVlbg==?= Microsoft ASP .NET 4 12th Aug 2004 01:37 PM
RE: vb.net coding standards Tian Min Huang Microsoft Dot NET Framework 4 13th May 2004 10:42 AM
Re: vb.net coding standards Mark Broadbent Microsoft Dot NET Framework 0 12th May 2004 06:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.