Derik Whittaker

Syndication

News


Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
[OT] Where Do Automatic Properties go in your class file?

Ok, so I know this is a odd question but I am stumped.

Normally when I have a private instance level variable that is exposed via a property I format my class file as such.

{

..... all instance variables

..... any constructors

..... any public/private/protected methods

..... any properties

}

Now that we have Automatic Properties, there is no need for instance level variables.  So, do I put the property where I would have put the instance level variable?  Or do I put the property where I would normally put it?

I am leaning towards putting the Automatic Property where I would have normally put my properties.  Why, well because if I need to change it from an Automatic Property to a 'standard' property I will not have to move it in my class file (btw, I am anal with my class file organization).

So, I am asking.  Where do they go?

Till next time,


Posted 02-02-2008 8:37 PM by Derik Whittaker

[Advertisement]

Comments

Igor Brejc wrote re: [OT] Where Do Automatic Properties go in your class file?
on 02-03-2008 4:19 AM

I'm using a different philosophy: I put all of the public stuff at the front and (private) instance variables at the end of the class. My thinking is that most people will first want to know what the class offers to the outside world. Only the minority will want to look deeper into the internals. So this is a rough list:

1. public properties

2. public constructors

3. public methods

4. protected ....

5. private ...

6. private fields

It's not perfect and it does have some issues, but at least it doesn't raise a problem with where to put automatic properties - they stay together with non-automatic ones.

sergiopereira wrote re: [OT] Where Do Automatic Properties go in your class file?
on 02-03-2008 11:42 AM

Why would you need to change it from an automatic property syntax back to a complete declaration?

Anyway, I organize my code by functional context rather than language constructs (we had that discussion before,) but in your layout I'd definitely put the properties together with the other properties.

Derik Whittaker wrote re: [OT] Where Do Automatic Properties go in your class file?
on 02-03-2008 12:12 PM

@Sergio,

Why, well you never know.  

There have been cases before where you add logic to a setter, getter.  I know it is not always the best, but lets be honest, it happens.

Joey Beninghove wrote re: [OT] Where Do Automatic Properties go in your class file?
on 02-03-2008 11:11 PM

Umm, wherever R# puts them when I hit Ctrl-Alt-Shift + F.  :D

Derik Whittaker wrote re: [OT] Where Do Automatic Properties go in your class file?
on 02-04-2008 6:34 AM

#Joey,

You and your keyboard shortcuts.  What does Ctrl-Alt-Shift + F do?  It did not do anything with my 3.1 install and with my 2.5 it just 'flickered'.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)