Geeks With Blogs
Greg Young Greg.ToString()

http://geekswithblogs.net/AzamSharp/archive/2005/11/23/61046.aspx just read this to make me think about it.

Partial classes are NOT new people. They have been supported in IL since the 1.0 version of the framework. I personally think MS would have been far better off spending the 2 hours it took to implement this in C# to implement rethrow (which also has existed in IL without a C# construct) or static methods on interfaces which also fits the same order.

I find the example convoluted, if your classes are so big that you need to isolate them into 5 or 6 seperate files chances are its your design that has the problem. The thought that by putting my properties in one file, my methods in another, and my variables in yet another does not simplify the process since chances are if I am making any sort of substantial change to these items I will need to check out the lot of them.

I really hope this is not the best answer MS can come up with to make up for the lack of quality merging capabilities in VSS.

Excuse the rant.

Posted on Wednesday, November 23, 2005 9:52 PM | Back to top


Comments on this post: Partial classes

# re: Partial classes
Requesting Gravatar...
I think your missing the real value of partial classes, which is best seen in most of the new features of ASP.NET 2.0. The real advantage comes from being able to use the CodeDom to dynamically create pieces of a class which are merged together with user-created pieces at runtime. Thinking of partial classes in this context gives architects and developers a large new set of scenerios that can be designed.

I agree that the sample you linked to is a fairly lame example of using partial classes, and your spot on that in the vast majority of cases, of your classses are so big that you need to seperate them into partial classes, you have some bigger problems than that.
Left by MIssing the point on Nov 23, 2005 11:33 PM

# re: Partial classes
Requesting Gravatar...
As posted above, the biggest benefit of partial classes is the separation/merging of "AutoGen'd" code from code you hand craft. Creating a "user code sensitive" code AutoGen has to be complicated and prone to overwrite the programmer's intentions.
Left by Eric Newton on Nov 24, 2005 1:36 AM

# re: Partial classes
Requesting Gravatar...
Is this not solved as well through inheritance?
Left by Greg Young on Nov 24, 2005 1:49 AM

# re: Partial classes
Requesting Gravatar...
Perhaps I have not refined my thoughts enough in my post. The functionality it offers can in 95% of cases either be offerred in other ways or it is being abused as in the case listed which is pure insanity.

I see far more instances of someone doing something like the case in the example than the very few examples it was intended for. I honestly believe the real intention is to hide alot of the autogenerated code from developers who are too stupid to realize not to change it (I guess defining a region named "Autogenerated code" and the placement of comments telling them to not change it was not enough!

This said there are numerous other changes like the ones I mentioned which would have huge design benefits that have been overlooked. Instead we end up with a piece of fluff functionality that really carries relatively little design significance and will be misused to a magnitude.

I brought up these questions in a MS sponsored group and the response I received was "Typed Datasets need this functionality since you can't use inheritance with them", well my response to that is they must have a design problem because people in the persistance camps have been generating code and keeping it seperate from user code for years.


Left by Greg Young on Nov 24, 2005 2:04 AM

Your comment:
 (will show your gravatar)


Copyright © Greg Young | Powered by: GeeksWithBlogs.net