UML – Sequence Diagram Editor


If you’re running on a Mac and using UML, there’s a limited number of editors available to you that are worthy of mention.

One tool I found myself using recently is the “Quick Sequence Diagram Editor” sdedit, which can be found here: http://sourceforge.net/projects/sdedit/.

To use this, you will to ensure that Java is already installed as the program downloads as a jar file.

Install and Launch

  1. Download the jar file from here: http://sourceforge.net/projects/sdedit/files/
    This will download the file sdedit.jar
  2. Copy sdedit.jar to you Application folder or folder of your choice
  3. Navigate to the jar file, right-click on it and select Open
    This may warn you that this is untrusted software downloaded from the internet.
    Simply accept this and continue
  4. The application will open up and look like the screenshot before

001.sdedit.blank

 

Create a Simple Diagram

Now let’s create a very simple diagram.

The first thing you will notice is that there are no widgets to drag into place.  All the widgets are added by entering code into the text pane at the bottom. This is documented in the help text which can be accessed by clicking on the blue help button.

Add the Objects to the Sequence Diagram

into the bottom panel enter the following text to add an Actor and objects for a BookingService, Booking and SchedulesCourse

delegate:Actor
bs:BookingService
b:Booking
sc:ScheduleCourse

note: the Objects are declared in the form <name>:<type> (see the help for more options)

This will give us the following:

002.sdedit.objects

Add the methods

The methods must be separated from the Object declarations by a blank line.

Create a blank line and then enter the following code

delegate:bs.bookScheduledCourse(schedId,numPlaces)
bs:delegate.SUCCESS/FAILURE

note: the Methods are declared in the form <source-name>:<target-name>.description (see the help for more options)

This now gives us the following:

003.sdedit.delegateCall

Let’s add the calls from the bookingService to the other objects. Our complete code will look like this:

delegate:Actor
bs:BookingService
b:Booking
sc:ScheduleCourse

delegate:bs.bookScheduledCourse(schedId,numPlaces)

bs:b.createBooking()
b:sc.[checkAvailability(schedId,numPlaces)='true']

b:sc.allocatePlaces(schdedId,numPlaces)

bs:delegate.SUCCESS/FAILURE

This gives the following:

004.otherMethods

Next, let’s add some destructors for our Booking and ScheduledCourse objects

we do this by annotating the Object declaration at the top of the file with [x] to give:

delegate:Actor
bs:BookingService
b:Booking[x]
sc:ScheduleCourse[x]

delegate:bs.bookScheduledCourse(schedId,numPlaces)

bs:b.createBooking()
b:sc.[checkAvailability(schedId,numPlaces)='true']

b:sc.allocatePlaces(schdedId,numPlaces)

bs:delegate.SUCCESS/FAILURE

note: the Objects that are destroyed are appended with [x] (see the help for more options)

and now our diagram looks like this:

005.withDestructors

Finally, let’s add a title to our diagram by adding a line to the top of our code as follows:

#![Skills421 - BookingService]
delegate:Actor
bs:BookingService
b:Booking[x]
sc:ScheduleCourse[x]

delegate:bs.bookScheduledCourse(schedId,numPlaces)

bs:b.createBooking()
b:sc.[checkAvailability(schedId,numPlaces)='true']

b:sc.allocatePlaces(schdedId,numPlaces)

bs:delegate.SUCCESS/FAILURE

and our end result will look like this:

006.finishedDiagram

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s