Mark Lorenz on Technology

Friday, March 03, 2006

MagicDraw tips for modelers

One of the best, if not the best object-oriented modeling tools IMO is MagicDraw. I have used multiple modeling tools over the years, including Visio (yes, Visio), Rational Rose, Embarcadero Describe, Paradigm Plus, and Omondo. By far, the best one I've used is MagicDraw from No Magic.

I've used MagicDraw for a couple of years now (from v8.x to v10.5 currently) and certainly learned some things along the way. This post is my attempt to share these lessons learned so others can bypass some pain along the learning curve.
Please contribute to this post if you have tips to share!

MagicDraw has a lot of power and different ways to use it. I have mostly used it as an Eclipse plugin (see diagram), but occasionally used it as a standalone product due to some plugin restrictions. I have also used it remotely (what they call "offline" - meaning not connected to the Teamwork Server that is the repository of modeling artifacts).



MagicDraw supports all the UML 2.0 diagrams, roundtrip engineering, sharing artifacts between modelers, and a lot more. See their site for all the details.

I've tried to organize the tips by categories, hopefully making it easier to find items of interest and skip those that may not apply to your situation. So, without further ado, here are my lessons learned:

General

  • Change your settings so that Operations do not show stereotypes or properties
Thanks to Patty Sullivan for this tip.
The default shows too much information IMO, cluttering up the diagrams. To simplify this, select Options/Project. In the resulting dialog, expand Symbols and then Shapes and select Class. Next, on the righthand side under Operations, change the Show Operations Stereotype and Show Operations Properties checkboxes to false. Select the Apply button to change your existing artifacts. Select OK to close the dialog.

Class Diagrams

  • Name the ends of your associations
If you do not, the resulting code will have variables declared as "_unnamed".
  • Set the ends of your associations to the correct type for a "many" cardinality
Otherwise, you will get the type declared in the resulting code instead of a Collection subtype. Open the specification of the association attribute, select Language Properties, then under your language (e.g. Java), pick the proper type for the Container.
  • Enter assertions as commentary on your classes and methods
This allows you to use tools like CodePro to create more meaningful JUnit test cases automatically. Check out my posts on TDD and CodePro.

Interaction Diagrams

  • Reverse engineer sequence diagrams from existing code
Enterprise edition only
Thanks to Patty Sullivan for this tip
If you have existing code, rather than create sequence diagrams Select Tools/Model Visualizer. In the resulting dialog, select the sequence diagram option and continue with the wizard from there to specify the details for your particular design.

Using MagicDraw as an Eclipse plugin

  • Increase startup resources
If you don't, you may run out of heap space, which is never a good thing. Here is what I've been using to start Eclipse (adjust to fit your situation):
C:\eclipse\eclipse.exe -vmargs -Xms256m -Xmx1024m -XX:MaxPermSize=128M
  • Use the standalone MagicDraw to generate reports
This is a bug as of the 10.5 release. It may have been fixed.
Report generation from the plugin does not work!
  • Watch for duplicate methods and variables
When you edit source in Eclipse (or WSAD or RAD), MagicDraw can't always tell whether you are replacing a method or variable or creating a new one. Even if you use refactoring to make changes, that doesn't cross the MagicDraw-Eclipse boundary. Similarly, if you make changes in MagicDraw, you may not end up with exactly what you want on the Eclipse side. So, depending on how you work and what settings you have for your Integration options, you can end up with artifacts that need to be cleaned up.

Miscellaneous

  • Use offline to take your model on the road
Thanks to Donatas Simkunas for this tip.
In order to work offline, the first thing you must select Options/Environment, then Floating and set "Auto login to floating license server" to false. This will take effect the next time you start your MagicDraw client. You will be offered an auto login option via a dialog at startup - do not check that option or you will not be able choose to work offline (this is also how you pick the type of license you want to use if you have more than one type).

When starting MagicDraw, you will get a dialog to choose which license you want to use (this is the second dialog - the first one is the license server login). Also on this dialog is the choice of "offline" or "online". You will choose offline. This allows you to work without a connection to the license or teamwork servers for a certain period of time.
Note: The period of time is set by default to 24 hours. You can change this setting by editing the Offline Session Time value on the Users tab of the Administrator's Console.

Note: The only artifacts that you will be able to change in offline mode are ones you have created without committing them to the Teamwork Server and ones that you have specifically locked for editing. This is done via a menu action and causes your login ID to appear next to the artifacts in the Containment Tree.
When you are done working offline, you should choose Help/Finish Floating License Session. Make sure you have visibility to the Teamwork Server as this will reconnect you. If you exceed the time for working offline, you will not be able to start your MagicDraw license until you have access to the MagicDraw server.
  • Adjust server settings
Thanks to Vilma Lukoseviciene for this tip
There is no way to tell the MagicDraw server that a particular client is logged off, such as when a client system has crashed. However, you can change the duration of time that it takes for the connection to time out, thereby dropping the user and freeing the license.

To do this, you should login to the Teamwork Administrator's Console and change
(decrease) the values for the muserver.ping.time and muserver.ping.timeout.time
in the Properties tab. After changing these properties you need to restart the Teamwork Server.

The muserver.ping.time is the time interval for the Teamwork Server to ping clients. After sending a ping, the server waits for an answer from the client. If an answer is not received during the muserver.ping.timeout.time interval, the user is logged out (and can therefore log back in).

Unsupported Functionality

No tool has everything. Here are some features that I'd like to have, but MagicDraw does not currently (v10.5) support:
  • More support for refactoring
E.g. I've wanted to be able to change a class into an interface or vice versa. You can't. You have to create the one you want yourself, but MagicDraw does make it easy to move methods, variables, and relationships (just DnD).
  • Sorting of methods within the class properties dialog does not work
This is a known bug and may be fixed when you read this. If it doesn't, it's not something you're doing wrong.
  • Using MagicDraw with AndroMDA doesn't work for MagicDraw 10.x
This used to work, but currently (as of 10.5) this no longer works. So, use MagicDraw 9.x if you want to use AndroMDA. If you've already got a MagicDraw 10.x project, you are out of luck - MagicDraw is not backwards compatible. Again, this may have been fixed, so check it out.

Troubleshooting

When things go wrong, you are going to want to send your md.log file in your MagicDraw home directory (you can edit this down to smaller size if it's getting large) as well as screen snapshots and/or code as appropriate. Here are some known problems and why they might occur:
Symptom: Classes you know exist are not available.
Possible reason: Depending on the template you chose when you created a project, different classes will be available. Not to worry if some you need are missing - select File/Import and browse to the templates directory and import the file(s) you need (e.g. java.util.xml.zip for Java 1.4.2 classes).

Thanks to Patty Sullivan for this tip.
Symptom: Existing classes fail when attempting to reverse engineer.
Possible reason: The Java version may not be correct for the code. E.g. Parsing works differently using Java 1.5 or 1.4 as the target. Use Options/Project/Code Engineering/Java to change the target version.

Thanks to Patty Sullivan for this tip.
Symptom: You cannot edit a class, method, association, ...
Possible reason: You may not have everything involved locked for edit. E.g. to edit an association, you must lock the association and the elements at both ends.
Symptom: Names of transitions on state diagrams do not appear on the diagram.
Possible reason: You have to specify the names as the trigger and choose SignalEvent as the type to get the names to appear.
Thanks to Nerijus Jankevicius for this tip.
Symptom: When trying to login, a dialog says you are already logged in.
Possible reason: You probably just crashed your client for some reason. MagicDraw license server is supposed to free up your license after a timeout period. It doesn't always work. The only way I know to get back in is to stop and restart the MagicDraw server.

Resources

Labels: , , , , , , , ,


1 Comments:

  • New tip: select Options/Environment, then set "Save project recovery data on idle" to false.

    This will stop MagicDraw from "stealing" your cursor. When the cursor focus is grabbed, random things can happen (e.g. characters you are typing in an email might be entered into a selected class' name).

    By Blogger Mark, at March 16, 2006 12:17 PM  

Post a Comment

<< Home