Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



Nice side affect of Automatic Properties

Today it dawned on me another nice little side affect of automatic properties.

I was creating an interface today that ONLY had properties and when I was done I needed to create the concrete object that implemented said interface.  All I had to do was copy, paste and add the modifier (public) to each line. 

In the past I would have had to create the private member variables and setup the formatting correctly.  Now I do not have to.  Saved me a solid 5 minutes of busy work.

+1 for saving me time.

Till next time,


Published Apr 29 2008, 01:17 PM by Derik Whittaker
Filed under:

Comments

Luke Foust said:

I noticed this benefit too! The difficult thing is if you have a property that is not a primitive type, then you have to provide some sort of initialization for that object before it can be used. So then I end up having to convert the automatic property to being a "regular" property or add a constructor to my class. Do you have this pain?

# April 29, 2008 3:22 PM

Matt Hinze said:

I use R# for this.. Alt-Enter, Implement members, Select All, Continue, Property generation -> Auto-property, Finish

# April 29, 2008 3:29 PM

Derik Whittaker said:

@Matt,

Well, I just back with R#.  We broke up for a while.

Plus.  I could not remember that many key strokes if i tried.  Brain cannot handle more than 2 things at once. :)

# April 29, 2008 3:36 PM

JaredPar said:

I agree this is goodness and I think it would also be nice if this was just the standard behavior for the VS smart tag "Implement Interface".  Instead it generates empty properties that throw.  Trivial to delete and add back the auto-property but it would be nice if it just did this already.  

# April 29, 2008 4:41 PM

jkay said:

And by blogging about it, your'e back to square one ;-)

# April 30, 2008 2:51 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News