Thursday, March 22, 2007

Visual Studio makes your properties!

This is something I already know for a while but it's a very handy features which the Visual Studio developers have made quite hard to find. When your declaring your business logic / domain classes, this feature will surely be handy. When you want to encapsulate a private/protected field (the good OO way...), you'll probably make accessors for it. Writing all of these getters & setters is a lot of work if you've got around 10 attributes you want to cover.

Here's the trick, just right click the field you want to encapsulate


And Visual Studio will create the property methods:

Everybody who has coded with Visual Studio before is probably aware of this tip but for new coders, this is a real timesaver!

The other refactoring options are also extremely handy for code optimization. The Extract Method options is also one of the features I use quite frequent...


No comments: