Book a Demo

Author Topic: how to update model when code updated  (Read 4175 times)

James007

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
how to update model when code updated
« on: January 13, 2012, 02:41:20 am »
I develope my Java code in one machine and I keep my UML model in another machine. I did the reverse engineering from my code to generated some diagrams and found something is not right. After I added new packages and new files. I copied the new code over and removed the old code. Then I want to the new model reflect the new code. But I cannot find a working way to do it. I tried "Synchronize Package with Code" under the "Code Engineering". It will not delete the files/packages which are deleted in the code. It will not add the files/packages which are added in the code. If I do "Import Source Directory ...", which was I did at very beginning, again, it will have another code tree added. Basically I have some diagrams exist already, I don't want to start over again whenever my code is changed.

And when I move packages/files from one place to another in the Project Browser window by drag and drop. I found the package name in the files is not changed accoordingly. That is not right, I think.

Can you help me about this. I am new on your tool. thanks,
« Last Edit: January 13, 2012, 02:44:21 am by ilove007 »

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: how to update model when code updated
« Reply #1 on: January 17, 2012, 08:52:39 pm »
I have a similar issue and hopefully there is a workaround.
Initially, I imported my C# code in EA (Import Source Directory) which worked ok.
It yielded the fact that 3 classes had no namespace defined. Hence the code has been updated via Visual Studio to define the appropriate namespaces.
Once done, I ran "Synchronize Package with Code" ; the 3 classes have been updated but they haven't been moved to the appropriate package to reflect the new namespace. Any clue?

thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: how to update model when code updated
« Reply #2 on: January 18, 2012, 08:43:08 am »
James007, if it's creating a new code tree, it's likely that your code has moved location. I've posted a number of times about how to correct that using EA's local paths feature.

Guillaume your problems will be solved by doing another Import Source Directory.

Jerome777

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: how to update model when code updated
« Reply #3 on: January 18, 2012, 11:11:03 pm »
Simon, I code in Java and I have exactly the same problem than James007 and Guillaume, and it is not a problem of "local path" (which is correctly configured), but rather a problem of update of the model after a refactoring of the code.

For example, when you rename a class, or a method in a class, in your IDE, you have to do the same thing in the EA model prior to reverse engineering operation, otherwise EA will create for you another class or method in the model and you'll loose the link between current diagrams entities and updated classes or methods.

It is worse if you decide to move a class to another package (like Guillaume explained with defining other namespaces in C#), since moving the class in the model is not sufficient : you have to patch the filename property of each moved class, before the reverse engineering, otherwise EA will create new classes in the same EA package, with different filenames. I don't imagine doing this manually for many classes...  :(
In this particular case, it would be nice if EA could patch automatically filename property of moved classes, to reflect current package.

Do you confirm that model and code should be both modified in the way I explained, before the next reverse engineering operation can be done, or is there another (easier) way to do this ? Refactoring is a so common operation in Java that I hope you have a trick for this  :-/.

Regards