Академический Документы
Профессиональный Документы
Культура Документы
vogella.com
Tutorials
Training
Books
Contact us
116
Training Books
bug fixes and enhancements
by Lars Vogel
09.10.2008
UML with Eclipse and the UM2Tools This article gives a short overview of UML2 and explains the usage of the Eclipse UML2 Tools for modeling UML 2 diagrams. This article is based on Eclipse 3.5.
Table of Contents
1. UML 1.1. Overview 1.2. Definition 1.3. UML Profiles 2. Installation of Eclipse UML2 Tools 3. Eclipse UML2 Tools 3.1. Creating UML Diagrams 3.2. Multiplicity 3.3. Interfaces 3.4. Viewing the .uml file 4. Appendix: Class diagrams 4.1. Overview 4.2. Classes 4.3. Attributes 4.4. Interfaces 4.5. Relationships 4.6. Export your class diagram as image 5. Appendix: Model-Driven Architecture (MDA) 5.1. Overview 5.2. Platform Independent Model (PIM) 5.3. Platform Specific Model (PSM) 5.4. Code Mode 6. Thank you 7. Questions and Discussion 8. Links and Literature
1. UML
www.vogella.com/articles/UML/article.html 1/12
21/05/13
1.1. Overview
Eclipse supports the creation of UML2 diagrams via UML2 Tools project. UML2 Tools is a set of GMFbased editors for viewing and editing UML models.
1.2. Definition
The Unified Modeling Language (UML) is a visual language for capturing software designs and patterns. The first version of UML was defined 1994 and released by the Object Management Group (OMG) in 1997 as UML v.1.1. The syntax and a semantic of UML is defined by the OMG. The basic building block for UML is a diagram. UML divides diagrams into structural diagrams and behavioral diagrams The latest version UML 2 has the target to add the ability for modelers to capture more system behavior. UML 2 has the target to support model driving architectures (MDA). MDA has the target to create automatically a software program from several models.
www.vogella.com/articles/UML/article.html
2/12
21/05/13
Press finish. From the "Palette" you can now select the type of element you would like to create. For example Select "Class" and click in the whitespace to create the UML representation of a class.
www.vogella.com/articles/UML/article.html
3/12
21/05/13
The properties view allow you to change the attributes of the elements. To open the properties view select a class, right-click and select "Show Properties View". You can then for example set the "Is Abstract" flag to true to create a abstract class. If you select your element a menu will be displayed which allows you to add property (fields) and operations (methods).
If you select your UML diagram and click on the outgoing arrow you can create associations.
Tip
www.vogella.com/articles/UML/article.html
4/12
21/05/13
You can edit the properties and the operations names directly in the diagram. According to the UML specification the name of an operation should be followed by round brackets, e.g. you can type foo() but not foo for a operation.
Tip
Note that your UML diagram updates the *.uml file. In case you deleted your diagram you can re-create the diagram from the .uml file, via the right-click and by selecting the "Initialize * class diagram" entry in the menu.
3.2. Multiplicity
You can maintain the relationship multiplicity between two classes by clicking on the association and via the properties lower / upper in the property view.
www.vogella.com/articles/UML/article.html
5/12
21/05/13
3.3. Interfaces
UML2 Tool let you choose if you want to use the ball-and-socket notation (interface is displayed as a circle) or UML stereotype <<interface>> for the representation of an interface. Simple right-click on the interface and select "Show as class" of "Collapse to circle".
www.vogella.com/articles/UML/article.html
6/12
21/05/13
4.2. Classes
A class is represented by a retangular box divided into compartments. A Compartment is an area in the box to write information. The first compartment holds the name, the second holds the attributes and the third is used for the operations.
Any compartment can be hidden to improve readability of the diagram. UML suggests that a class name: Starts with a capital letter is centered in the top compartment is written in a boldface font is written in italics if the class is abstract
4.3. Attributes
Attributes specifies details of a class and can be simple types or objects. Attributes can be defined inlined (as part second compartment of the diagram of the class) or as relationship. 4.3.1. Inlined Attributes Inlined attributes are placed in the second compartment of the class. The notation for inline attribute is:
www.vogella.com/articles/UML/article.html
7/12
21/05/13
visibility + # ~ name type multiplicity default myName
4.3.2. Attributes by Relationship To model attributes by relationship you use an association relationship between the class which represents the attribute and the class containing the attribute.
4.3.3. Static Attributes Static attributes (attributes that are part of the class and not part of the instance of the class) are displayed via underlining the name of the relationship.
4.4. Interfaces
Interfaces are indicated via the stereotype <<interface>> .
www.vogella.com/articles/UML/article.html
8/12
21/05/13
4.5. Relationships
UML defines several ways of representing relationships between classes. 4.5.1. Association Read as "..has a.." association between classes. Drawn as a straight line between the two classes. Does not mean that the classes are owned by one, other classes may use the connected class too.
4.5.3. Composition Strong relationship between classes to the point of containment. Read as "..is part of..". If the owning instance is destroyed then normally (not necessarily) the linked object is destroyed too.
www.vogella.com/articles/UML/article.html
9/12
21/05/13
4.5.4. Generalisation Read as ".. is a..". Use to express inheritance. Represented by a solid line and a hollow triangular arrow. For example the following code could be expressed with the following diagram.
p a c k a g ea n i m a l s ; p u b l i ca b s t r a c tc l a s sA n i m a l{ }
p a c k a g ea n i m a l s ; p u b l i cc l a s sF r o ge x t e n d sA n i m a l{ }
www.vogella.com/articles/UML/article.html
10/12
21/05/13
6. Thank you
Please help me to support this article:
www.vogella.com/articles/UML/article.html
11/12
21/05/13
Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.com Google Group. I have created a short list how to create good questions which might also help you.
www.vogella.com/articles/UML/article.html
12/12