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.
Order by: Score:
VS 2003 vs. VS 2005
by Smeagol on Mon 16th Jan 2006 00:20 UTC
Smeagol
Member since:
2006-01-16

Kind of on-topic:
Anyone have an opinion of of VS 2003 vs VS 2005?

My experience in the past is that initial major releases of MS dev tools have always been shaky. What's 2005 like?

Lastly, anyone know of a good online review of 2005 (or one that compares 2003 & 2005)?

Thanks!

Reply Score: 1

RE: VS 2003 vs. VS 2005
by n4cer on Mon 16th Jan 2006 00:36 UTC in reply to "VS 2003 vs. VS 2005"
n4cer Member since:
2005-07-06

You can download the Express Editions (free products) or get a trial version of Pro or Team System here:
http://msdn.microsoft.com/vstudio/

You can also try out Visual Studio online at the MSDN Virtual Labs:
http://msdn.microsoft.com/virtuallabs/default.aspx

Reply Score: 1

unthinkableMayhem
Member since:
2006-01-16

The article seems to focus on partial classes allowing multiple programmers to make changes to the same class. This is suggested as a workaround to the failings of sourcesafe.

As far as I can tell the only legitimate use for partial classes is to separate my code from that generated by the designer (no more "Designer generated code" regions, yay!) which I think is a good thing.

I can just imagine the mess in the source tree from using partials to separate programmer's work:

class.cs - Original class.
class_2.cs - Someone else needed to add a method.
class_bs.cs - Oh, Brad worked on it too...
class_3.cs - You get the idea.

Perhaps use a decent source control system instead?

:]

Reply Score: 3

nberardi Member since:
2005-07-10

I have to totally agree with you. A programmer with limited knowledge and an active imagination is the nightmare of any code maintainer.

You can really see the benifit of partial classes when you start using ASP.NET and XAML in Avalon. This allows you to potentially give a designer the interface to create and then pass the work to the developer. I beleive this is Microsofts plans and I thought I saw a product that alluded to this.

Well either way it is a bad idea in this article to allude this will help with source control. The person who wrote this article is probably the type of coder that I alluded to above.

Reply Score: 1

n4cer Member since:
2005-07-06

You can really see the benifit of partial classes when you start using ASP.NET and XAML in Avalon. This allows you to potentially give a designer the interface to create and then pass the work to the developer. I beleive this is Microsofts plans and I thought I saw a product that alluded to this.

The product is Expression Interactive Designer (codenamed Sparkle):

http://channel9.msdn.com/ShowPost.aspx?PostID=116394

http://www.microsoft.com/products/expression/en/interactive_designe...

Reply Score: 1

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 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 Score: 1

Code separation
by snowflake on Mon 16th Jan 2006 03:13 UTC
snowflake
Member since:
2005-07-20

I never understood why Microsoft never separated the automatically generated GUI code from the manually generated code in VS. It's not as if they didn't have an example to compare with, that is Borland's Delphi. It is even stranger that they didn't do this from the beginning given that Anders Hejlsberg was one of the orginal designers of Delphi. There is some separation now in VS2005, but in VS2003 it's all mixed up.

Reply Score: 2

logical separtion
by Leoandru on Mon 16th Jan 2006 06:40 UTC
Leoandru
Member since:
2006-01-15

why would a interface coder and core coder want to work in the same file? Though decoupling core logics and interfaces into seperate modules/files is the way to go.

Reply Score: 1

RE: logical separtion
by Matzon on Mon 16th Jan 2006 07:18 UTC in reply to "logical separtion"
Matzon Member since:
2005-07-06

then fix that issue by doing resource files or stuff like that - dont let world+dog implement a class over 15 files, it WILL BE ABUSED!

Reply Score: 1

LMAO
by l3v1 on Mon 16th Jan 2006 12:46 UTC
l3v1
Member since:
2005-07-06

From the article:
A pessimist might wonder [...]Visual SourceSafe doesnít support multiple simultaneous checkouts of the same file and isnít known to merge file differences with eloquence and grace[...]SourceSafeís tolerable deficiencies are somewhat mitigated.

:D How very nicely put ;)

In my world, we use better version/source control systems instead of inventing newer keywords ;)

Reply Score: 1

Oh My God
by segedunum on Mon 16th Jan 2006 15:23 UTC
segedunum
Member since:
2005-07-06

There are several advantages to splitting these elements into many files, including permitting more than one developer to work on the same class.....A pessimist might wonder......Whether intended or not, a nice benefit of partial classes is that SourceSafeís tolerable deficiencies are somewhat mitigated.

Well, I am a pessimist when it comes to SourceSafe and if you think you should be using it maybe you should be considering another career. SourceSafe is not acceptable as a source control system under any circumstances, nor are half-baked ways of getting multiple developers on the same piece of code.

No, twice no, thrice no. Get a proper source control system and communicate with each other when developing. Chopping classes up into further parts just adds to the communication, complexity and development overhead.

Additionally, that's what refactoring is about. If your class is too large maybe you should be looking at your classes a bit harder and splitting them up, or looking at your analysis and design?

Youíll find the partial keyword used in Windows Forms classes to split the part thatís managed by the designer and the part where you add your code into two separate files.

All this is is a way for Microsoft to sell you Team System, which is conveniently split up into architect and developer components, where each cost money and have separate licenses of course.

Edited 2006-01-16 15:26

Reply Score: 1

More Screwball Ideas from Microsoft...
by MikeekiM on Mon 16th Jan 2006 18:34 UTC
MikeekiM
Member since:
2005-11-16

This is what you get when you don't have a Community Forum. Dumb ideas.

Microsoft developers are the scariest in the world.
- Like Static classes in Enterprise code.

Learn to code OOP first, before reinventing.

Reply Score: 1