Page 1 of 1

Please use existing model information to supplement reverse engineering

PostPosted: Sat Jan 13, 2001 2:53 pm
by Andrew McVeigh
Hi,
(apologies for the HTML posting -- I have some pictures in the explanation)

I have noticed that MagicDraw, when reverse engineering, offers a choice of either creating elements as attributes ("create attributes for class members") or associations. It then gives the option of turning an attribute into an association, via "create roles".

The problem with this is that it doesn't make use of any information in the current model! Consider:

1) I reverse a class Person into the model with attributes "name: String" and "born: Date"
2) I turn "born" into a role, and leave name as an attribute
3) I add an operation to Person.java and reverse into the model again

Now, I am faced with 2 options -- either turn "name" and "born" into attributes, or turn them both into associations!!
However -- the model already records that I want "name" as an attribute and "born" as an association!

So, rather than just the option "create attributes for class members", it would be much better to add:

"create attributes for class members, and reuse any existing model information"

Otherwise, roundtripping is seriously tiring -- each time I reverse a class, I have to fix up all my associations again. This can be serious, as I have to re-add things like multiplicities, whether the association was a composition, an aggregation, how it was navigable etc.

---------------------------------------------------------
Advanced features:

Rational Rose does the above (and very well I might add) and takes the whole thing 1 step further. Consider that I have (in Java):

class Customer
{
private Vector accounts;
}

class Account
{
}

Now, in Rose, when I reverse in Customer and Account, I get a Customer having a 1 to 1 association with a Vector. Not very useful. E.g:

But I can modify this link in the model to the following:


Now, (and here is the clever part), when I reverse engineer the classes again, Rose keeps my model the same, and uses the information in the model to infer that the Vector is just an implementation detail of the association between Customer and Account. It actually sets the code generation property of the association (ContainerClass) to "Vector". This is quite an amazing feature, as it means that reverse engineering never loses any model changes made in the case tool.

Please, please, please find a way to implement this in MagicDraw. It is soooo close, but until these features are added, reverse engineering will not be particularly useful in MagicDraw for medium and large size projects. I should know -- I just reverse engineered over 200K lines of code into a preexisting model in Rose, and kept almost all my model changes. I do this sort of thing often. I would never attempt the same thing in MagicDraw.

Regards,
Andrew McVeigh,
London, UK



Re: Please use existing model information to supplement reverse engineering

PostPosted: Mon Jan 15, 2001 6:54 am
by Paule Zaksauskiene
Andrew,
Thank you for producing us the MagicDraw UML inconvenient usability
problems.
If you want to reverse the Java code leaving the attributes and
relationships the same, try to select
"Merge model and code" and leave the "Create attributes for all class
members" unchecked in the Reverse options dialog box. Then the model
and code are merged, attributes and roles are not changed, but model is
updated from reversed Java files.
This option will help to resolve the problem you described for the
Customer, Vector and Account classes. It also helps to save the old
association type: aggregation, composition. Now when the "Change model
according to code" is selected the Java code is reversed changing all
the associations to the composition relationship.

When the "Create attributes for all class members" is selected
attributes are generated, despite the selected
"Merge model and code" option button. We will try to fix this problem in
the nearest future.

The multiplicities and navigability are not saved for the attributes, so
we will consider how to resolve this problem.

Regards,
--
Paule Zaksauskiene
Quality Assurance Engineer
UAB No Magic
P.O. box 2166, LT- 3000, Kaunas
Phone: +370 7 324032 Fax: +370 7 320670
e-mail: paule
WWW: http://www.nomagic.com