Book a Demo

Author Topic: Partial classes  (Read 4939 times)

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Partial classes
« on: December 08, 2005, 09:21:13 pm »
OK, so I've got a copy of Visual C# 2005 Express.  It creates partial classes for everything it feels like.

has anyone got any good ideas for handling these monsters?

bruce

"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Partial classes
« Reply #1 on: December 12, 2005, 06:54:46 pm »
Good question!

I wish I had a good answer.  Instead I'll offer some things to discuss.

Visual Studio 2005 class diagrams (Not UML of course) display it as a single class.  The only indication I can see about the partial class is that the fields in the .Designer.cs file are greyed out.  The advantage of this is that it is a single class.  The disadvantage is that it doesn't allow you to see/specify in which file a member should appear.

EA reverse engineering currently creates two (or more) classes with a tagged value "partial".  Advantages being that you can specify where things go, and that it works easily with EAs existing code engineering. Disadvantages being that members and links are not shared and there is no way to draw the class as a whole.  An interesting thought on this on is that possibly they are the same thing (remember this thread?) but conveying different information about the class.

Any number of things are possible between those two extremes (possibly there are further extremes).  One possibility is to define the class and create all links to that, and then use inner classes for each partial part.

I look forward to other responses.

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Partial classes
« Reply #2 on: December 12, 2005, 10:25:37 pm »
Quote
An interesting thought on this on is that possibly they are the same thing (remember this thread?) but conveying different information about the class.
...or how to shoot yourself in the foot  ;D

Ah well, as Chaucer said "the lyf so short, the craft so long to lerne.".

"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Partial classes
« Reply #3 on: December 12, 2005, 11:17:32 pm »
Quote
Ah well, as Chaucer said "the lyf so short, the craft so long to lerne.".
We would do well to stop here with old "Saucy Chaucy" :-X

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: Partial classes
« Reply #4 on: December 13, 2005, 01:10:34 am »
Woow !!! Bit like the old Rose OO forum this.

Partial class declarations are synatic sugar.  Introduced by C#'s creators to make Microsoft's code generators less intrusive to it's coder user base.

The compiler / linker, merges these fragments to produce a single class.   UML2 has a merge relationship, quite a troublesome thing by all accounts( something to do with IBM not liking associations being functions; they settled on 'transformation' ).

Mearge is usually applied to Packages.  Package B, is merged with A.... to produce something that is more than both.   Like Aspect Programming....

Have a good time yeah

stay tough
Kevin

Hans

  • EA User
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Partial classes
« Reply #5 on: January 06, 2006, 05:08:30 pm »
Hi Sargasso,

 so please, do us .NET users a favour and join us in our complaints to Microsoft!
These partial classes are a pure misconception, btw mainly conceived to overcome the design failure within ASP.NET (where aspx files are not part of the Page class, but server sided main programs).

Partial classes are superfluous, and my advice is: don't use them!

Regards
Hans