Simple UML What is UML n n n

  • Slides: 15
Download presentation
Simple UML

Simple UML

What is UML? n n n UML stands for Unified Modeling Language UML is

What is UML? n n n UML stands for Unified Modeling Language UML is a diagramming language designed for Object. Oriented programming UML can be used to describe: n n n the organization of a program how a program executes how a program is used how a program is deployed over a network …and more 2

Design Patterns n n n Design Patterns describe the higher-level organization of solutions to

Design Patterns n n n Design Patterns describe the higher-level organization of solutions to common problems Design Patterns are a current hot topic in O-O design UML is always used for Design Patterns are used to describe refactorings We may discuss some Design Patterns later on in this course 3

UML is complex n n UML is a big, complicated diagramming language UML comprises

UML is complex n n UML is a big, complicated diagramming language UML comprises at least seven or eight different kinds of diagrams This talk will cover just a tiny bit of one kind of diagram, the class diagram A class diagram is often all that is needed to describe a particular Design Pattern 4

Class diagrams n n A class diagram shows classes, interfaces, and their relationships We’ll

Class diagrams n n A class diagram shows classes, interfaces, and their relationships We’ll cover most of classes and interfaces, and a few of the most important relationships 5

Classes n A class is drawn as a rectangle with two or three compartments:

Classes n A class is drawn as a rectangle with two or three compartments: Name of the class Variables [optional] Methods 6

Variables I n A variable is written as: visibility name : type where: n

Variables I n A variable is written as: visibility name : type where: n n n + means public visibility # means protected visibility - means private visibility <blank> means default (package) visibility Example: +length: int 7

Variables II n n n Static variables are underlined An initial value can be

Variables II n n n Static variables are underlined An initial value can be shown with =value Example: -number. Of. Employees: int=10 means number. Of. Employees is: n n private static integer and has 10 as its initial value 8

Methods n Methods are written as: visibility name (parameters) : return. Type where n

Methods n Methods are written as: visibility name (parameters) : return. Type where n visibility uses the same syntax variables (+, -, #, blank) parameters are given as name: type if the return. Type is void, it is omitted constructors are preceded by «constructor» interfaces are preceded by «interface» n an ellipsis (…) indicates omitted methods n n 9

Example of a class Card card. Id: int -copy: boolean=false «constructor» Card(int id) +is.

Example of a class Card card. Id: int -copy: boolean=false «constructor» Card(int id) +is. Kind(desired. Kind: int) +is. Sharable(): boolean +to. String(): String 10

Types of relationships A C Factory 1. . 4 B Class B extends class

Types of relationships A C Factory 1. . 4 B Class B extends class A D Class C contains 1 to 4 objects of class D creates Product Other kinds of relations 11

Example: Secret Code program 12

Example: Secret Code program 12

UML tools n Rational Rose is the “real world” standard; full roundtrip code generation

UML tools n Rational Rose is the “real world” standard; full roundtrip code generation n n Together (from Borland) is a lot like Rational Rose n n Recently acquired by IBM (right under Microsoft’s nose!) I haven’t used it in about five years (since before Borland bought it from Together. Soft) Argo. UML looks interesting (and is open source) Blue. J, of course, displays simple UML diagrams Drawing programs with UML support n n Visio is a Microsoft tool Dia is a freeware clone of Visio 13

Tool links n Rational Rose n n Together n n n http: //argouml. tigris.

Tool links n Rational Rose n n Together n n n http: //argouml. tigris. org Visio n Hard to find info on Microsoft’s site! n http: //msdn. microsoft. com/office/understanding/visio/ Dia n n http: //www. borland. com/together/ Argo. UML n n http: //www-3. ibm. com/software/awdtools/developer/rosexde/ hhttp: //www. gnome. org/projects/dia/ Omni. Graffle 3 (Mac OS X) n http: //www. omnigroup. com/applications/omnigraffle/ 14

The End 15

The End 15