Book a Demo

Author Topic: C# partial classes difficult to work with  (Read 3559 times)

Jacques_Ronaldi

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
C# partial classes difficult to work with
« on: September 28, 2012, 04:01:20 am »
Not sure if that's a bug or me missing something, but HOW am I supposed to work with c# partial classes? The problem is that after reverse engineering such a class, I simply end up with as many classes of the same name as there were files with the partial class.

How am I supposed to use that? How should I know which of those classes to drop on a diagram? Often the partial is only used to separate a bigger class into smaller chunked that are logically separated in files. I would expect to only drop a single object on a diagram, no?

Kevin G. Watson

  • EA User
  • **
  • Posts: 217
  • Karma: +0/-0
  • I love EVERYTHING including Microsoft
    • View Profile
Re: C# partial classes difficult to work with
« Reply #1 on: October 10, 2012, 02:43:57 am »
Hi'ya

There you go using language dependant features, that have no direct counterpart in UML, and you wonder why you gets odd results.

I haven't used EA for about 18 months, so cannot comment on current app.  But what you are describing is the same result as IBM RSA, RSA does use a dependency relationship with a 'Partial' stereotype so at least you can navigate / find / explore the distributed definition.  Doesn't help much if you're trying to answer the question have I got all the bits.

Partial classes where introduced to solve a very specific problem.  Code generated by the IDE ( think WinForm layout code ) was crowding out and making hard to find the tiny amount of code that a programmer was writing, change a little in the Ui and the file was reorganised and folks would have difficulty finding the bits.  By separating tool generated stuff from handwritten code, you made life much easier.

Separation of concerns, and aspect programming have all jumped on board and folks have found it useful... Thus it's propping all over the lace.  I've even seen it being used as a form of inheritance ( see how it's used in the Domain Specific Modeling framework ).


I'm not sure that combining the fragments into a whole is always going to be cool.  But I would think that a model to model transform would be the route to go.   Reverse-engineer into a Code Layout Model, apply transform to get model with all the partial classes combined.

Is there a property on the partial stereotype ( is there a stereotype ), for the source file the fragment is located.  If so then I would have thought that the transform would be trivial...  Adding new stuff would require a bit of extra work, which file does it belong in for example.

It's not a bug, and you're not missing anything... You're just been using a very non-UML'ey construct...  

Kevin [smiley=2vrolijk_08.gif]



Jacques_Ronaldi

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: C# partial classes difficult to work with
« Reply #2 on: October 10, 2012, 03:28:32 am »
Thanks Kevin. I thought so too, but then I guess I was just "hoping" that EA must have some cleaner way to work with those partial classes instead of VERY confusing classes with all the same name!! There is just no cue as to which is which. There's no free lunch it seems :)