8
 University of the Free State Department of Computer Science and Informatics 2012 UML Summary Supplementary notes for the module RIS264 Dr. Eduan Kotzé and Mr. Gavin Dollman

UML Summary 2012

Embed Size (px)

Citation preview

Page 1: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 1/7

 University of the Free State

Department of Computer Science and Informatics

2012

UML SummarySupplementary notes for the module RIS264

Dr. Eduan Kotzé and Mr. Gavin Dollman

Page 2: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 2/7

2 | P a g e  

UML Definition

Unified Modeling Language (UML) is a standardized general-purpose modeling language in the field

of software engineering. UML includes a set of graphical notation techniques to create abstract

models of specific systems.

Class Diagram

Figure 1

  Draw a class by placing the name of a class centered in a rectangle. Figure 1 shows three classes:

Firework, Rocket and RocketSim.

  There is no requirement in UML that a diagrams shows everything about an element, such as all

the methods of a class or the complete contents of a package.

  Indicate a package by placing the name of the package in a rectangle, left-aligned with a larger

box that may show classes and other types. For example, the classes in Figure 1 are in the

Fireworks package.

  When showing a class outside a package diagram, you may prepend the class’s namespace and a

dot to the class’s name. For example, Figure 1 shows that the RocketSim class is in the

Simulation namespace.

Page 3: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 3/7

3 | P a g e  

Contents of a Class

Figure 2

  You can show a class’s instance variables in a rectangle beneath the class name.

  The Firework class has the instance variables _ name, _mass and _price.

  Follow the variable’s name by a colon and the variable’s type. 

  It is general good practice to begin instance variables with an underscore, to distinguish them

from other variables.

  You may indicate that an instance variable or a method is private by preceding it with a minus

sign (-)

  A plus sign (+) indicates that a variable or method is public.

  A pound sign (#) indicates that a variable or method is protected.

  You can show a class’s methods and C# properties in a second rectangle beneath the class’s

name.

  Remember to show a property as a method with no parentheses.

  You may also show the type of a property by following it with a colon and its type.  Show a method that accepts parameters as the Lookup() method.

  Variables in method signatures usually appear as the name of the variable, a colon, and the type

of the variable.

  You may omit or abbreviate the variable name if its type implies the variable’s role. 

  Indicate that a method is static by interlining it, as the Lookup() method shows.

Page 4: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 4/7

4 | P a g e  

Comments in UML

Figure 3

  Make notes by drawing a dog-eared rectangle.

  The text in notes may contain comments, constraints, or code.

  Attach notes to other diagram elements with a dashed line.  Note can appear in any UML diagram.

Page 5: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 5/7

5 | P a g e  

Class Relationships

Figure 4

  Show a class name or method name in italics to indicate that the class or method is abstract.

  Use a closed, hollow arrowhead to point to a class’s superclass. 

  Use a line between classes to indicate that instances of the classes are connected in some way.

  A line on a class diagram means that one class has an instance variable that refers to the other

class.  The Machine class, for examples, uses an instance variable to retain a reference to a

 TubMediator object.

  Use a diamond to show that instances of a class contain a collection of instances of another

class.

  An open arrowhead indicates navigability. Use it to emphasize that a class has a reference to

another class and that the “pointed to” class does not have a back reference. 

  A multiplicity indicator such as 0..1 indicates how many connections may appear between

objects.

  Use an asterisk (*) to indicate that 0 or more instances of an object of a class may be connected

to objects of an associated class.

Page 6: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 6/7

6 | P a g e  

  When a method may throw an exception, you can show this with a dashed arrow (---->) pointing

from the method to the exception class.

  Label the arrow with a <<throws>> stereotype.

  Use a dashed arrow between classes to show a dependency that does not use an object

reference.

  For example, the Customer class relies on a static method from the LikeMyStuff class.

Interfaces

Figure 5

  You can draw an interface by placing the text << interface >> and the name of the interface

in a rectangle, as figure 5 shows.

  You can show that a class implements an interface with a dashed line and a closed, hollow

arrowhead.

  You can also show that a class implements an interface by showing a line and circle (a

“lollipop”), plus the name of the interface. 

  Interfaces and their methods are always abstract in C#.

  Oddly enough, interfaces and their methods do not appear in italics, unlike abstract classes

and abstract methods in classes.

Page 7: UML Summary 2012

7/31/2019 UML Summary 2012

http://slidepdf.com/reader/full/uml-summary-2012 7/7

7 | P a g e  

Object Diagram

Figure 6

  You can show an object by giving its name and type, separated by a colon.

  You may optionally show just the name, or just a colon and the type. In any case, underline thename and/or type of the object.

  Use a line between objects to indicate that one object has a reference to another.

  You can use an open arrowhead to emphasize the direction of the reference.

  You can show a sequence of objects sending messages to other objects, as the lower part of 

Figure 6 shows.

  The order of messages is top to bottom, and the dashed lines indicate the existence of the

object over time.

  Use the «create» stereotype to show that one object creates another.

  Figure 6 shows the ShowClient class creating a local Rocket object.

  Draw a darker, thicker box around an object to indicate that it is active in another thread,

process, or computer.

  Figure 6 shows a local Rocket object forwarding a request for its  Thrust property to a Rocket 

object running on a server

References

Metsker, S.J. (2004). Design Patterns in C#. Addison Wesley

http://en.wikipedia.org/wiki/Unified_Modeling_Language