Book a Demo

Author Topic: UML to C# correspondence  (Read 5820 times)

jnltech

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • OIT Prof.
    • View Profile
UML to C# correspondence
« on: July 10, 2006, 11:08:54 am »
Hello, I have been working with EA and C#. When I have a directional aggregate relationship from Class A to Class B such that the open diamond is on Class A, the aggregate that gets generated is in the C# code for Class B. This is opposite to that relaitonship described by Robert Martin as per the UML standard for UML to code relationships; however, is the same as that created for database relationships (makes sense for Primary-Foreign key relationships). How do I work around this without compromising my class diagrams?
« Last Edit: July 10, 2006, 11:14:56 am by jnltech »
James N. Long
Associate Professor
CSET Department
Oregon Institute of Technology
www.oit.edu

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: UML to C# correspondence
« Reply #1 on: July 10, 2006, 11:35:20 am »
You can reverse the visual direction of aggregation and composition relationships. That is, you can display them with the 'diamonds' on the other end than EA would normally show, without changing the semantic direction of the relationship. That may be what you need.

To do this, from the EA main menu choose Tools / Options and select the Objects page. Check the Draw Aggregations Reversed box (near the bottom of the left-hand column in build 791.
No, you can't have it!

jnltech

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • OIT Prof.
    • View Profile
Re: UML to C# correspondence
« Reply #2 on: July 10, 2006, 02:30:28 pm »
Thanks for the tip. I did as you suggested and I am getting inconsistent results. In one case, the aggregate resolves out in the cs classes fine. In the other instance, the aggregate is relsoved in the cs code in both the source and destination class. In this case, the collection has the same name. Both aggregates mentioned above have the same properties with the exception where the faulty generated aggregate is a 0..* relationship.
James N. Long
Associate Professor
CSET Department
Oregon Institute of Technology
www.oit.edu

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: UML to C# correspondence
« Reply #3 on: July 10, 2006, 04:18:21 pm »
Take a look at the other tabs on the attribute dialog. You can set some of the collection properties, including the intended class. This overrides the default setting in the Tools / Options / Code Generation page for C# (which you should also check).

If this does not get you anyplace let us know. Hopefully the Sharp guys or the other members will have seen this before.
No, you can't have it!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: UML to C# correspondence
« Reply #4 on: July 10, 2006, 04:42:11 pm »
Quote
Thanks for the tip. I did as you suggested and I am getting inconsistent results. In one case, the aggregate resolves out in the cs classes fine. In the other instance, the aggregate is resolved in the cs code in both the source and destination class. In this case, the collection has the same name. Both aggregates mentioned above have the same properties with the exception where the faulty generated aggregate is a 0..* relationship.
James,

Check whether the relationships are EA Associations or EA Aggregations.   (By opening the connector properties and noting the type on the dialog caption...)

The topic: WARNING: Aggregations vs Aggregate Associations may be of relevance.  The posting is over a year old, but the behaviour may still be anomalous.

Try searching the forum for "Aggregation Association".  The postings may have other information relevant to your problem.

HTH,
Paolo

BTW: Are you reverse engineering only, round-tripping or forward engineering only?
« Last Edit: July 10, 2006, 04:44:06 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

jnltech

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • OIT Prof.
    • View Profile
Re: UML to C# correspondence
« Reply #5 on: July 10, 2006, 09:13:50 pm »
Hi Paolo,

Yup, that was the issue. Aggragate Association is what is required to get the associations to generate properly.

I am round trip engineering.

Thanks.
James N. Long
Associate Professor
CSET Department
Oregon Institute of Technology
www.oit.edu