Book a Demo

Author Topic: Java Synchronization when Moving Classes  (Read 5219 times)

Robert DiFalco

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Java Synchronization when Moving Classes
« on: May 20, 2004, 12:15:58 pm »
Any idea how I can move a package or class(es) in EA and have it sychronize properely? i.e. move my files into the new package directories.

Why when I change a java class name does it not change the (.java) file name associated with the class?

Are there documented patterns for using roundtrip features in a way that is consistent with java source code?

Robert DiFalco

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #1 on: May 21, 2004, 04:44:13 pm »
Does the silence mean that this is not handled by EA? We are currently evaluating to see if our team should move to EA.

Christiaan

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #2 on: May 24, 2004, 07:58:18 am »
Hi,
I think the silence means precisely that, unfortunately. EA imho isn't that great when it comes to code synchronization. I already posted a feature request to improve it, since I think it is one of the most important features for model driven development. (And for your information, they are not very keen in reacting on these requests.)

I think the basic idea is, ones you establish a link between a class element and a file (which you can see in the filename property of the element), synchronization works (partly). As soon as this relation is broken, nothing will be synchronized.

Robert DiFalco

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #3 on: May 24, 2004, 11:00:29 am »
That's too bad. We are close to purchasing a bunch of copies for our team (it's a pretty large team) and this is the only hold-up so far. We just cannot figure out how to move a Java package or move/rename classes and still have the synchronization work.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #4 on: May 24, 2004, 03:53:52 pm »
Hi,

There are a few problems (at the moment) with renaming classes in the model.  The first one is general to all languages.  That is, EA finds the class (or anything) primarily based on its name.  If you change the name of a class EA won't recognise that it is the same class.  In some languages this will mean adding a new class to the file, in Java it will mean ignoring it.  This behaviour will persist until GUIDs are introduced.(Providing users choose to use them.)

In Java you also have the problem that you need the filename to match the class name.  So to correctly synchronise a class with a changed name (and or package) you need to change the filename in EA, the filename on disk and the class name within the file.

Here is my suggestion to handle that.  Create an add in for EA that before generation of any code checks to see if the class or package is different from what the filename suggests.  If it is it should change the EA filename to the appropriate new filename, rename and move the file as necessary and change the class name within the file.

At some point in the future EA could do this, but you could add that in for yourself until then.

Hope this helps.

Simon.

PS. Christiaan, this is primarily a user forum.  Even if Sparx staff do monitor it.  I did a search on your previous posts though and I'll respond to the one that I think you are referring to.  But I will say that EA code engineering is being improved constantly and some of the problems you mentioned in that post have been fixed.

Robert DiFalco

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #5 on: May 24, 2004, 04:30:51 pm »
Well, I guess I just assumed that if you renamed or moved a class or package within EA, that it would first reassociate the existing GUID(s) to the new name/location and if you were using java (i.e. mapping packages to directories) EA would appropriately move/rename files and update the file name fields. Isn't this how other tools work?

Nonetheless, we are really enjoying our eval of EA. It just is doesn't seem to be a good "roundtrip" solution (so far) for those who like to refactor their code.

Christiaan

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #6 on: May 25, 2004, 02:44:18 am »
I agree with you. EA supports a broad range of functionality when it comes to modeling (that's why we bought it;), but for roundtripping you really need some written down procedures (and discipline). Since the license price is that low compared to other modeling products, we can live with the workaround, and we keep on looking forward to the code synchronization improvements, of course.

By the way simonm, I posted the requests on this forum after I (and some colleagues) had sent several emails to sparx with no reaction at all. I had already noticed the bugfix concerning the proper package statement and that works fine now. (Another by the way, I also tried build727, I got a ADODB.recordset[-2...] error on synchronizing a java class. After that, EA exits. Unfortunately I cant reproduce the error, since I already synchronized it using 726)

angel-o-sphere

  • EA User
  • **
  • Posts: 112
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #7 on: May 27, 2004, 10:08:31 am »
Hi,

for Java I suggest to have a custom documentation tag in the comment describing the class ... or the file.

That tag could be named @ea-guid and should hold the GUID of the class. Of course the user would be expected not to change that line of text.

The problem we have is we heavyly use IDEs with refactoring support. That means Classes regulary change their package name or their class name or both.

EA needs to track the date of the last export (code generation) and the internal changes inside of EA. E.g. in case an attribute and a method got added. A simple but expensive (in terms of development efford) solution would be to provide an Eclipse PlugIn for EA ... so refactorings in Eclispe could be kept in synch ...

I know its not well liked if a CASE system stores internal informations in source code comments, however the need for refactorings on source code level with the IDE is very high.

Currently we make waterfall development ... from UCs starting we finally have a simple class model which we export. After that we reimport from time to time ... but due to the "dublicated class names in different packages" bug the source and model can not be kept in synch. Basicly we have an UML model without classes and a second repository with classes only ... not very good :-/

With stored GUIDs the problem could be softened.

Regards,
  angel'o'sphere

Christiaan

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Java Synchronization when Moving Classes
« Reply #8 on: June 01, 2004, 11:45:50 pm »
Although I dont think EA needs our implementation suggestions to implement the requested features, wouldn't it be a better simpler if users could specify a link between an EA (root) package and a folder on the network or local drive. On synchronizing, EA could scan the specified folder to see if:
- classes have been added to or deleted from the package
- subpackages have been added