Linked by Eugenia Loli on Sun 15th Jan 2006 23:19 UTC
.NET (dotGNU too) Partial classes permit splitting a single class, interface, or struct into multiple, separate files. There are several advantages to splitting these elements into many files, including permitting more than one developer to work on the same class. Paul Kimmel shows where partial classes are used and how you might use partial keywords to fine-tune your productivity.
Thread beginning with comment 86071
To read all comments associated with this story, please click here.
DHofmann
Member since:
2005-08-19

If you're tempted to use partial classes, then your "god class" really ought to be split up into multiple, smaller classes. This is known as "refactoring". Once you've done this, you won't need to split up a class definition file into multiple files. Your code will be easier to understand and maintain, and there will be less of a likelihood that multiple developers will want to work on the same class at the same time.

I'm worried that developers will flock to partial classes because it encourages poor structural design.

Reply Score: 3

jsight Member since:
2005-07-06

I totally agree... partial classes are barely a good idea for generated code (mostly getting around poor navigation features in VS.Net IMO), and an extremely bad idea for anything else.

Reply Parent Score: 1

nberardi Member since:
2005-07-10

Generated code seperated from actual code is always a good thing. Definitely when you start throwing mark up langauges on top of the compiled code. In the case of ASP.NET and XAML it is a great thing. So that developers can work on code and designers can work on interfaces. I am not saying the process is perfect, but it is getting closer to the intent than ever before.

Reply Parent Score: 1