15
Aug 16, 2 022 Simple UML IB Computer Science

31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

Embed Size (px)

Citation preview

Page 1: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

Apr 20, 2023

Simple UML

IB Computer Science

Page 2: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

2

What is UML?

UML stands for Unified Modeling Language UML is a diagramming language designed for Object-

Oriented programming UML can be used to describe:

the organization of a program how a program executes how a program is used how a program is deployed over a network …and more

Page 3: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

3

Design Patterns

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 Design Patterns are used to describe refactorings We will discuss some Design Patterns later on in this

course

Page 4: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

4

UML is complex

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

Page 5: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

5

Class diagrams

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

Page 6: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

6

Classes

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

Name of the class

Variables [optional]

Methods

Page 7: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

7

Variables I

A variable is written as: visibility name : typewhere: + means public visibility # means protected visibility - means private visibility <blank> means default (package) visibility

Example: +length:int

Page 8: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

8

Variables II

Static variables are underlined An initial value can be shown with =value Example:

-numberOfEmployees:int=10

means numberOfEmployees is: private static integer and has 10 as its initial value

Page 9: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

9

Methods

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

Page 10: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

10

Example of a class

Card

cardId:int-copy:boolean=false

«constructor» Card(int id)+isKind(desiredKind:int)+isSharable():boolean+toString():String

Page 11: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

11

Types of relationships

A

B

Class Bextendsclass A

C

D1..4

Class Ccontains

1 to 4 objectsof class D

Factory

Product

creates

Other kinds ofrelation

s

Page 12: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

12

Example: Secret Code program

Page 13: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

13

UML tools

Rational Rose is the “real world” standard; full round-trip code generation Recently acquired by IBM (right under Microsoft’s nose!)

Together (from Borland) is a lot like Rational Rose I haven’t used it in about three years (since before Borland

bought it from TogetherSoft) ArgoUML looks interesting (and is open source) BlueJ, of course, displays simple UML diagrams Drawing programs with UML support

Visio is a Microsoft tool Dia is a freeware clone of Visio

Page 14: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

14

Tool links

Rational Rose http://www-3.ibm.com/software/awdtools/developer/

rosexde/

Together http://www.borland.com/together/

ArgoUML http://argouml.tigris.org

Visio Hard to find info on Microsoft’s site! http://msdn.microsoft.com/office/understanding/visio/

Dia http://www.lysator.liu.se/~alla/dia

Page 15: 31-Oct-15 Simple UML IB Computer Science. 2 What is UML? UML stands for Unified Modeling Language UML is a diagramming language designed for Object- Oriented

15

The End