unified modeling language - idatddd78/pdf/2015/tddd78... · 1996: toomany modeling languages slower...

15
[email protected] – 2015 Unified Modeling Language A Brief Introduction

Upload: others

Post on 15-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

[email protected] – 2015

Unified Modeling Language

A Brief Introduction

Page 2: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

2

jonk

v@id

ajo

nkv@

ida

2History In the early 1990s, three common OO modeling approaches James Rumbaugh's

Object-modeling technique (OMT)

Grady Booch's Booch method

Ivar Jacobson’sObject-Oriented Software Engineering(OOSE)

Page 3: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

3

jonk

v@id

ajo

nkv@

ida

3History (2) 1995: All three employed at Rational Software Known as The Three Amigos

1996: Too many modeling languages slower adoption of OO Wanted a non-proprietary language using the best parts Formed an international consortium

Result: Unified Modeling Language, UML Not a development method, just a language

Used to build a system model Part of this model can be represented

as various forms of diagrams

Page 4: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

4

jonk

v@id

ajo

nkv@

ida

4UML Diagram Types We will focus on class diagrams!

Page 5: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

5

jonk

v@id

ajo

nkv@

ida

5Usage Guidelines Why use class diagrams?

To design software before coding▪ Create a broad structure, check that it is consistent and reasonable

To help you understand existing code▪ Create a structural overview▪ Can be faster to construct and to understand a diagram

than a long text describing the same thing

How should they be used? Less is more

▪ Focus!▪ Illustrate one coherent subsystem at a time▪ Include only as much as you need

Page 6: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

6

jonk

v@id

ajo

nkv@

ida

6Simple Class Diagram General structure of a class:

ArrayList

elements: Object[]length: int

size() : intget(int amount): Objectadd(Object element): Objectset(int index, Object element): void

Class Name

Attributes

Operations (methods)

Static members: Underlined!Colors are not part of the standard –

added here for clarity!

Page 7: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

7

jonk

v@id

ajo

nkv@

ida

7Visibility Markers Visibility markers before names + Public # Protected – Private ~ Package / Derived (computed from other attributes) Also, static methods or fields are underlined

ArrayList

–elements: Object[]–length: int

+size() : int+get(int amount): Object+add(Object element): Object+set(int index, Object element): void

Page 8: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

8

jonk

v@id

ajo

nkv@

ida

8Interfaces General structure of an interface: Interface name in italics Marked with the <<interface>> ”stereotype”

List <<interface>>

+size(): int+get(int amount): Object+add(Object element): Object+set(int index, Object element): void

Page 9: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

9

jonk

v@id

ajo

nkv@

ida

9Realization Class Relationships: Realization An interface is simply a description Classes realize the interface:

Provide a concrete implementation Dashed arrow, unfilled arrowhead Members shown:

▪ Where they are declared for the first time▪ Where they are implemented / overridden

List <<interface>>

+size(): int+get(int amount): Object+add(Object element): Object+set(int index, Object element): void

ArrayList

–elements: Object[]–length: int

+size() : int+get(int amount): Object+add(Object element): Object+set(int index,Object element): void

LinkedList

–head: Object–tail: LinkedList

+size() : int…

SkipList

+size() : int…

Page 10: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

10

jonk

v@id

ajo

nkv@

ida

10Generalization Class Relationship: Generalization (inheritance) List specializes Collection (adds new requirements, new methods) Collection generalizes List Ordinary line, unfilled arrowhead

List <<interface>>

+get(int index): Object+set(int index, Object element): void

Collection <<interface>>

+size(): int+add(Object element): Object+contains(Object element): boolean

Page 11: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

11

jonk

v@id

ajo

nkv@

ida

11Generalization 2 Class Relationship: Generalization (inheritance) GraphicCircle specializes Circle Circle generalizes GraphicCircle Ordinary line, unfilled arrowhead

GraphicCircle

+outline, fill: Color

+draw(DrawWindow): void

Circle

+x, y, r: double

+getArea(): double

Page 12: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

12

jonk

v@id

ajo

nkv@

ida

12Composition Instance Relationship: Composition A hand is part of a person If we "remove" the person, its hands also removed Line with filled diamond

May add multiplicity▪ Every person has two hands, every hand is part of one person

Person Hand

Person Hand1 2

Omit fields/methodswhen they are not relevant!

Page 13: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

13

jonk

v@id

ajo

nkv@

ida

13Aggregation Instance Relationship: Aggregation

Alternative 1: In our model, a car is permanently linked to its wheels

Alternative 2: In our model, we can buy new wheels, or even swap wheels between cars Wheels can exist without cars

Car Wheel1 0..*

Car Wheel0..1 0..*

Page 14: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

14

jonk

v@id

ajo

nkv@

ida

14Association Instance Relationship: Association A person subscribes to zero or more magazines A magazine has zero or (hopefully) more subscribers The connection is not as close as between a car and its wheels

May name an association (or composition / aggregation)

Person Magazine

Person Magazinesubscribes

0..* 0..*

0..* 0..*

Page 15: Unified Modeling Language - IDATDDD78/pdf/2015/TDDD78... · 1996: Toomany modeling languages slower adoption of OO Wanteda non-proprietary language using the best parts Formed an

15

jonk

v@id

ajo

nkv@

ida

15Other UML Diagrams