executable uml the models are the code - executable uml lecture 3 - modelling with domains and...

26
Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Upload: darrell-ryan

Post on 30-Dec-2015

235 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

The Models are the Code -Executable UML

Lecture 3 - Modelling with Domains and Classes

Paul Krause

Page 2: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Lecture 3 - Modelling with Domains and Classes Partitioning complex projects

Domains and Domain Charts

Class Modelling within Domains

Page 3: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

One Thousand Classes and Beyond

We have to partition the problem. But how?

Functional decomposition is a traditional option

But typically a function represents a “vertical”slice through a system requiring application expertise knowledge of service functions - security, logging, … understanding of database functionality software architecture and implementation knowledge

In general, there are too many dependencies

Page 4: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Subject Matter Partitioning

Sally Shlaer and Stephen Mellor established the foundations for this approach in 1988 Object-oriented Systems Analysis - Modelling the

World in Data

Recognises that a system consists of a set of subject matters - domains Each domain consists of a set of classes Domains are represented as packages in UML

A Domain Chart captures the dependencies between domains

Page 5: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Air Traffic Control System

Air Traffic Control

EquipmentConfiguration

Alarms

User Interface

Radar DataProcessing

Page 6: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

What is a Domain? A domain is an autonomous, real, hypothetical

or abstract world inhabited by a set of conceptual entities that behave according to characteristic rules and policies Mellor and Balcer, p30

Real Worlds Air traffic control, patient administration, banking,

Hypothetical Worlds 3D geometry, statistical analysis, …

Abstract Worlds User interface, messaging, workflow, …

Page 7: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Domain Policies

Aircraft

Air Traffic

Control

Domain “Aircraft” Class represents a real world concept

Domain Policy: An Aircraft must remain atleast 3 miles horizontally and 100 vertically

from all other Aircraft

Icon

User

Interface

Domain “Icon” Class represents an abstract concept

Domain Policy: An icon must become opaqueif it is in front of another icon

Page 8: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Advantages of Subject Matter Partitioning Reuse

Well-defined interfaces

Effective use of subject-matter knowledge

Stability to changing requirements

Stability to changing technology

Incorporation of third party software

Effective integration with Use-Case driven development

Page 9: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Domain Types

Command and Control

Application DomainsRepresents the purposeof the system from theend-user’s perspective

Recording

Service DomainsProviding generic servicesto support the applicationdomains

User Interface

SoftwareArchitecture

Architecture DomainRepresenting the globallyapplied design and codingstrategies

Oracle

Implementation DomainsRepresenting pre-existingsoftware components - eitherbought-in or ‘legacy’

Unix

Page 10: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Domain Partitioning

Flight Plan Aircraft Runway

IconPop-upMenu

1

has filed

has beenfiled for

0..*

0..1

is beingused by

is using

0..1

represents 1

is represented by 1

1

is linkedto

has

1

Page 11: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Air Traffic Control

User Interface

Domain Partitioning

Flight Plan Aircraft Runway

IconPop-upMenu

1

has filed

has beenfiled for

0..*

0..1

is beingused by

is using

0..1

1

is linkedto

has

1

Page 12: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Lecture 3 - Modelling with Domains and Classes Partitioning complex projects

Domains and Domain Charts

Class Modelling within Domains

Page 13: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Class Modelling within Domains

A class is an abstraction of some set of conceptual entities with common characteristics and common behaviour

Note the two activities Classification Abstraction

There are various kinds of “conceptual entities”, not just tangible things

Page 14: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Kinds of Classes Tangible things

Aircraft, Book, Car, Pet, …

Roles Doctor, Clerk, Employee, Department, …

Incidents Flight, Performance, Accident, Service Call, …

Interactions Purchase, Credit Card Charge, Database

Transaction, …

Specifications Insurance Product, Book Product, Credit Card Type,

Page 15: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Classes and Objects

An Object

Is a chunk of structured data in a running software system

Has properties that represent its state Its behaviour may depend on its state

Has behaviour how it acts and reacts to events and messages

Page 16: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Classes and Objects

A Class

Is an abstraction of a set of objects that are similar in some useful way its instances

Film is a class

“Anger Management” is an instance of Film

Page 17: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Classes and Objects

Film

titledirectorproducerduration

: Film

title: Anger Managementdirectorproducerduration

Page 18: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Identifying classes

Think about general properties of the domain in which you are working

Identify the nouns

These form candidate classes

A Publisher produces and markets a Book

A Customer purchases a Book

An Author writes a Book

Page 19: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Publisher Book Customer

Author

Page 20: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Publisher

nameaddresswebSite

Book

bookNumbertitleunitPrice

Customer

nameemailshippingAddress

Author

nameaddresswebSite

Page 21: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Associations

Publisher

nameaddresswebSite

Book

bookNumbertitleunitPrice

R1

publisher publication

Publisher

nameaddresswebSite

Book

bookNumbertitleunitPrice

R1

is producedand

marketedby

producesand

markets

Page 22: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Association Meanings

Name the association so that it can be unambiguously identified (e.g. R1)

The “association ends” express meaning

An association end may be a role or a verb phrase

Each class in an association has a role (e.g. a Book has the role of a publication)

But writing meaning in terms of a verb phrase is more descriptive

Page 23: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Publisher

nameaddresswebSite

Book

bookNumbertitleunitPrice

Customer

nameemailshippingAdd

Author

nameaddresswebSite

R1 R3

R2

is producedand

marketedby

producesand

markets

purchases is sold to

wrote

was written by

Page 24: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Multiplicity

We can also characterise an association by the number of instances (objects) that participate in each instance of the domain relationship

UML allows specific numbers in a multiplicity relation

Recommend you only use four kinds: unconditional; 1, or 1..* conditional;0..1, or 0..*

Page 25: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Publisher

nameaddresswebSite

Book

bookNumbertitleunitPrice

Customer

nameemailshippingAdd

Author

nameaddresswebSite

R1 R3

R2

is producedand

marketedby

producesand

markets

purchases is sold to

wrote

was written by

1 0..* 1..* 0..*

1..*

1..*

There are books not sold to any customer

To be a customer you must have purchased at least one book

But where do I put the number of books a customer purchased?

Page 26: Executable UML The Models are the Code - Executable UML Lecture 3 - Modelling with Domains and Classes Paul Krause

Executable UML

Publisher

nameaddresswebSite

BookProduct

bookNumbertitleunitPrice

Customer

nameemailshippingAdd

Author

nameaddresswebSite

R1 R3

R2

is producedand

marketedby

producesand

markets

is apurchase

of

is sold as

wrote

was written by

1 0..* 1..* 0..*

1..*

1..*

Order

quantitysalePricedate

makes 1..*

is made by 1