At last Visual Studio 2005 beta 2 is out, but that’s not important now… What is important is some of the features that have been added. One feature that I was not interested in, and a little bit unhappy that they added, was Partial Classes. My main language for the past 7 years had been Delphi. Delphi has an interesting scheme where the properties are stored in one file, and the code is stored in another. Because of the way Delphi did things, these properties could be a real problem, as they were not part of the code, and sometimes did strange things when loading.

My initial understanding of Partial Classes was to implement something along the same lines, one file has the properties, and another has the code. I thought, "Delphi all over again, ugh". It turns out that there is a real need for partial classes. At my work, we are using Typed Datasets. These are very good, BUT they have a couple of issues. Any code added to the class that is generated will disappear the moment you make a change and regenerate the class.  To get around this, a co-worker came up with the idea of having the generated classes be a base class, and adding code and anything else to a derived class.  It’s a very good solution, but it takes a little bit to understand, and needs a tool to propagate certain changes out to the derived class.  Partial classes REALLY help this.  Now all code that we want to add can be placed in the partial class file.  The part that is auto generated can be regenerated over and over, and the code we add never has to change.  YEAH!!!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s