Using MyEclipse: UML


Laurie Williams, Ben Smith and Sarah Smith
CSC 326 - Software Engineering
Department of Computer Science
North Carolina State University

Back to Software Engineering Tutorials



0.0 Outline
1.0 Background/Installation
2.0 Registering MyEclipse
3.0 MyEclipse Perspectives
4.0 UML with MyEclipse
5.0 Exercises
6.0 Resources

1.0 Background/Installation

UML

UML (Unified Modeling Language) was developed by Grady Booch, James Rumbaugh, and Ivar Jacobson, at Rational Software Corporation in 1997, for a standard way to model the structure of large applications. The UML is a standard maintained by the Object Management Group (OMG). The current version of UML is 2.0. UML provides a standardized way of modeling software, so the everyone can understand a given model. UML has several different modeling types: class diagram, sequence diagrams, state charts, and use cases to name a few. This tutorial will introduce programmers to creating class diagrams in Eclipse UML.

MyEclipse is an application configuration for Eclipse which extends the functionality of the IDE immensley. Its features include complete support for developing web applications and UML modeling.

IMPORTANT:

It is recommended that users of this tutorial have a moderate understanding of the basics of the Eclipse development environment. If you do not know Eclipse basics, we recommend you read The Eclipse Tutorial also located on this website.

Installing MyEclipse

In order to install and use MyEclipse, you must have Eclipse preinstalled. You can download a trial copy of MyEclipse from their website or if you are an North Carolina State student, simply check the MyEclipse option in the web installer for your course.

Sequence Diagrams

A sequence diagram is a visual representation of how objects in a system interact. These interactions are captured in a single scenario, which is a specific path of behavior in a system for a particular use case or set of use cases. A program will have many different scenarios. A sequence diagram will contain the objects that are part of the scenario and the messages that are passed between the objects or participants of the scenario.

An object or participant is represented by a box with a dashed line vertically out the bottom of the box. The line represents the lifeline of the object. When an object is active (a method is running) a rectangle is on the lifeline. Messages are represented as dark triangle arrows. An object can send a message to another object by calling the second object's method. An object can also send a message to itself by calling one of its own methods. Returns from a method are represented by a dashed arrow.

Objects may create or delete other objects during the first object's lifeline. Loops, conditionals, etc may also be represented in a sequence diagram.

Top | Contents

2.0 Registering MyEclipse

MyEclipse is shareware which will expire in 30 days. If you have been provided a registration number as part of a course or for a company, read on in this section for the steps to register your copy. If you do not have a registration number, skip this step.

To register MyEclipse, you will need both a Subscriber ID and a Subscription Code. After opening your copy of MyEclipse, within any perspective, go to the "MyEclipse menu" and select "Update Subscription..." as demonstrated in figure 2.1.


Figure 2.1: Subscribing to MyEclipse

A dialog box will appear asking for your Subscription's ID and Code. Enter these and click "Okay." Your copy of MyEclipse is now registered.

Top | Contents

3.0 MyEclipse Perspectives

The perspective MyEclipse has to offer in which we are most interested is the UML perspective. The steps below will show you how to load this perspective in your workspace. The other perspectives can be quite useful, however, especially when developing a web application. To switch to the UML perspective, go to the icon next to the Java perspective in Eclipse and select the "MyEclipse UML" from the dropdown menu as shown in figure 3.1.


Figure 3.1: Loading the UML Perspective

Here is a quick list and description of the other perspectives MyEclipse has to offer:

  • Database Explorer: After it is configured properly, this perspective allows you to view the status, structure and data contained within your databases. This is to avoid having to write code which shows you the contents of your entire database.
  • Image Editor: Just like any other image editor, except you can edit the images contained within your projects, do image mapping and manipulate image behavior based on Java events.
  • J2EE Development: Allowing views of the current status of your system on any web development platform, this perspective automates deployment of your project to the server, and allows you to manage and configure the server.
  • Web 2.0: This perspective allows live editing of JSP and AJAX, two web interface technologies that are on the cutting-edge of the web world.
Top | Contents

4.0 UML with MyEclipse

MyEclipse makes synchronization of your code with a UML repository a snap. Before continuing through the various steps, you should make a decision as to whether you would like to create a possible design for your project before writing any code and then have MyEclipse generate the skeleton classes (Forward Engineering) or use code that you have already written to generate design diagrams either for documentation or communication (Reverse Engineering).

Sections 4.2-4.3 demonstrate how to generate diagrams using the UML perspective and then use them as a source to generate your Java basecode. Section 4.4 shows you how to reverse engineer your Java code into a diagram. Section 4.5 demonstrates how to take the diagrams within your project and export them as images for ease of use.

4.1 Creating a UML Repository

In MyEclipse, all UML must be contained within a repository. For different versions of a program or different levels of collaboration and development, one could have different repositories. Resositories are one file in MyEclipse, but they are still not source code or libraries, so we recommend placing them in a folder called /doc. To create a UML repository, go to File -> New... and select UML Model Repository from the dropdown menu that appears as in figure 4.1.


Figure 4.1: Creating a UML Repository

A dialog box will appear asking you which folder you would like to create the repository within, select your documentation folder or any folder that is not a source folder and click "Okay". Your repository will load within the perspective.

4.2 Creating diagrams

After you have completed section 4.1 or already have a UML repository, you can create UML diagrams using the MyEclipse editor. When your repository is showing within the MyEclipse UML perspective, you should see a toolbar that looks like figure 4.2a.


Figure 4.2a: Creating a new diagram

Hover your mouse over each button to see which type of class it creates. The classs types from left to right in figure 4.2a are class, use case, sequence, activity, state, collaboration and deployment.

Now is a good time to discuss the properties view. When you load any diagram within the MyEclipse UML perspective, the properties view will appear at the bottom of your screen (see figure 4.2b).


Figure 4.2b: The Properties

This editor will allow you to manipulate the various facets of any object within your UML repository. From the repository itself all the way to an element within an action that is a trigger of a transition of a state that is within a state diagram... you get the idea. Proper use of the properties view requires a knowledge of UML and Java.

Upon creating a diagram, you should also see a set of buttons for each type. The following figure show the buttons for sequence diagrams (figure 4.2c). Hover your mouse over each to see what type of element it allows you to create.


Figure 4.2c: Sequence Diagram buttons

To create each element, click the button and click within the diagram where you would like the place the element. It will appear as an "anon" element until you edit its properties (see figure 4.2b).

4.3 Exporting Images

Many people do not have MyEclipse and cannot open the files with which it stores UML Model Repositories (UMR). The most universal way to share UML is through an image file. This allows other developers (or perhaps your professor or TA) a brief view of the structure of your system in an easy to open format. To export your diagram as an image, you need to be in the MyEclipse UML perspective, have the diagram predrawn and have it showing. Then, right click on the image and select "Export as Image..." as shown in figure 4.5. We recommend keeping a backup copy of your UML diagrams in your /doc folder for easy publishing.


Figure 4.5: Exporting as an Image

Top | Contents

5.0 Exercises

These exercises will help you to learn how to use MyEclipse's UML perspective to model the system with the CoffeeMaker project (documentation, project files). Download the project files and import them into your workspace to begin. When you have completed each exercise, show your work to your TA for lab credit.

The Exercise

Create a sequence diagram in the models folder for the following scenario:

A student creates a new recipe Hot Chocolate with a price of $.50, 0 units of coffee, 1 unit of milk, 2 units of sugar, and 3 units of chocolate. Next, the student purchases a hot chocolate from the CoffeeMaker, and receives change of $.20.

Top | Contents

6.0 Resources

  • MyEclipse Documentation
  • Download Eclipse
  • UML Resource Page
  • Top | Contents

    Back to Software Engineering Tutorials
    Installing Eclipse Plug-ins ©2006 North Carolina State University, Laurie Williams, Sarah Smith , Ben Smith
    Email Sarah Smith with any questions or comments about this tutorial.
    Last Updated: Wednesday, July 26, 2006 1:46:50 PM