Round-Trip Engineering

Generating code and reverse engineering that same code still does not make round-trip engineering. Reverse-engineering generates a new model from existing code, but it does not by itself reconnect the existing code to an existing model. This feature is only available with the RoundTrip UML/Java Plug-in. It is one of the most recommended and highly sophisticated features provided by Poseidon for UML.

Generate a UML model from your existing code, change the model, re-generate the code, change the code and so on. All generated Java code files are watched, so that changes you have made with an external editor are imported into Poseidon's model of your project. Use your favorite source code editor to edit method bodies, add or remove methods and member variables. Poseidon keeps track of all changes, and all your project data is in one place — in Poseidon.

Please note that the round-trip plug-in is primarily an import tool; it imports changes in the source code for you and updates the model as necessary. Automatic code generation in the background is not yet implemented, but will be in one of the next minor releases.

How to use this plug-in:

And the changes will appear in Poseidon!

Some words on how to handle accessor methods:

You should unset the check box Generate accessor methods after you have generated accessors once. Otherwise, they would be generated again, and would clutter up your classes. The preferred way to create set/get methods is by adding them in an attribute's Properties tab, and by checking Create accessor methods for new attributes in the dialog Edit—Settings.

Figure 11-5. Java Code Generation — Settings.

In the code generation settings dialog, you have the ability to specify an additional classpath for compilation.

You might temporarily have non-compiling source code that you do not want to import into Poseidon right away. For these instances, you can temporarily disable the automatic import with the button next to the Import sources button. It will turn to red, showing that automatic round-trip is disabled. By clicking it again, it will turn back to green, designating that round-trip is enabled again.

Figure 11-6. Toolbar with Round-trip Button.

When the round-trip plug-in is running and you have imported files, Poseidon asks if you would like to keep these source files and the model in sync.

When you load a new model, Poseidon asks you if you want to generate the source code now or if you want to import existing source code. Choose the first alternative if the you want to ensure that the source code you have reflects the current model. Using the latter choice (import), you can synchronize the code and model even if you have changed the source code while Poseidon was not running and thus could not keep track online of the changes you did to the source.

Note that a folder for the source code is always set in Poseidon. This may not be the one that is suitable for your new project. To change it, select 'Update' and view the contents of another folder. This way, you can make sure that after opening a project, you can either update the project with the correct source code (and select option 2), or generate fresh code if the project is the latest version (select option 1).