3

I've created class diagram. Each class has its attributes and operations.

Then I created Object diagram. On this diagram I put instances of my classes. And I define Run State for each attribute.

During several iterations we have some of the attributes renamed or deprecated or deleted. Is there a way to refactor class diagrams in a right way? So that when I rename an attribute of a class in class diagram it is also changed in object diagram(where this class was instantiated)? I assume there should be some kind of refactoring feature in EA, cause renaming is just one of the refactoring tasks.

I use Sparx Enterprise Architect 8.0

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Theo Walcott
  • 41
  • 1
  • 7

1 Answers1

2

EA actually does that for you. Just open your object diagram first. Then select your class in the project browser and drag it onto your object diagram. EA will then ask you how to paste it. Select "instance (object)". Any changes that you make to the class afterwards should immediately be reflected in any instance (object). I created a test case with a class named "class". After instantiating it, I renamed the int property from "sdf" to "sdff". The corresponding object property was changed by EA. Also a deleted property was deleted from the instances automagically.

Tested with EA 10 (I don't have v8 installed but it is very likely to work the same way).

observer
  • 2,925
  • 1
  • 19
  • 38
  • As far as I can remember this works with v8.0 too. Using this helps to avoid redundancies. – MOnsDaR Jan 18 '13 at 22:47
  • I expected it to work that way, but it didn't. I'll check again in 10 and in 8.0 versions again later – Theo Walcott Jan 19 '13 at 18:20
  • It looks like I'm missing smt. I tried it in new project, and after renaming the attribute of the class it didn't change in object. Could you post your project somewhere? When I rename an attribute in class and then go to object runstate(ctr+shift+r) it shows me an old attribute plus it also shows a new one – Theo Walcott Jan 21 '13 at 07:52
  • Have you tried the same in EA 10 to rule out the possibility of a version problem? You can download a free trial from Sparx. I have created the demo in EA 9.1 now, the oldest I could get right now, and you can find it here: https://www.dropbox.com/s/iw20ospsgy948yq/objectTest.eap Please see the notation :Class1 which indicates what class the object is an instance of. – observer Jan 21 '13 at 09:44
  • 1
    [link](https://www.dropbox.com/s/rrte6dwie35pqmq/objectTest.eap) I've done the following: set run state for the object myObject by clicking ctr+shift+r, and set sdff = 123. After that I went to Class1 and renamed its property sdff to sdff1. Gues what? It didn't reflect this changes in myObject. And now you can go to set run state for myObject and see that there are two attributes for it(even though the Class1 has only one). Check out my .eap project in the beginning of the reply. Am I missing smt? Wanted to try IBM Rational Software Architect, but it is sluggish as hell, so maybe later – Theo Walcott Jan 21 '13 at 16:34
  • OK. Now I understand what exactly you have tried. So EA reflects the change in the attribute list of both the class and the object, but it preserves old name+value in the instance's run state. (You might want to rephrase the title of your question because the refactoring of the class diagram ain't the problem - but the object state.) By the way, what is your use case for your scenario? Maybe there is a workaround other than switching to another software... – observer Jan 21 '13 at 17:04
  • The use case is as follows: our team develops a UI designer and I am modeling user interface. First I distinguish which classes should be used as a prototypes for each UI block in our designer. After that, when I have a class diagram, I actually try to model the mockups of UI by instantiating classes to objects, and defining each attribute of the object. So this way I see wether or not my class model fits. While discussing my modeling with stakeholders I need to make changes in the model, it might be just an attribute renaming or it can be a new attribute with complex type definition. – Theo Walcott Jan 22 '13 at 07:40
  • I've posted this issue in the [Sparx forum](http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1359370430/0). Maybe they'll know a fix or workaround. – observer Jan 28 '13 at 10:55