47
Chapter 2, Modeling with UML, Part 1

Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Embed Size (px)

Citation preview

Page 1: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Chapter 2,Modeling with UML, Part 1

Page 2: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Aperçu du cours Trois façon d’aborder la complexité

Abstraction et modélisation Décomposition Hiérarchie

Introduction à la notation UML Revue des diagrammes :

Diagramme de Cas d’utilisation Diagramme de Classes Diagramme de Séquence Diagramme d’états Diagramme d’activités

Page 3: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system
Page 4: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Quel est le problème avec cedessin

Page 5: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Abstraction• Les systèmes complexe sont difficile à comprendre

• Le phénomème 7 + 2• Notre mémoire à court terme ne peut pas stocker

plus de 7 +- 2 pieces en même temps => limitation du cerveau

• Mon numero de tel est: 498928918204

Page 6: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Abstraction

• Découpage en morceaux: • Grouper les objets en collections pour réduire la

compléxité• 4 morceaux:

• State-code, Area-code, Local-Prefix, Internal-Nr

• Les systèmes complexe sont difficile a comprendre• Le phénomème 7 + 2

• Notre mémoire à court terme ne peut pas stocker plus de 7 +- 2 pieces en même temps => limitation du cerveau

• Mon numero de tel est: 498928918204

Page 7: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Abstraction

Phone Number

Country-Code Area-Code Local-Prefix Internal-Nr

• Découpage en morceaux: • Grouper les objets en collections pour réduire la

compléxité• 4 morceaux:

• State-code, Area-code, Local-Prefix, Internal-Nr

Page 8: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Abstraction• L’abstraction permet d’ignorer les détails non essentiels• Deux définitions pour l’abstraction :

• L'abstraction est un processus de pensée dans lequel l’idée s’éloigne des objets

• Abstraction comme activité• L’abstraction est l'idée résultant d'un processus de

pensée dans lequel l’idée s’est éloignée d'un objet • Abstraction en tant qu'entité

• Les idées peuvent être exprimées par des modèles

Page 9: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Models Un modèle est une abstraction

d'un système Un système qui n'existe plus Un système existant Un système avenir à construire.

Page 10: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

2. Techniques pour gérer la complexité : Décomposition Une technique utilisée pour maîtriser la

complexité (“divide and conquer”)

Deux grands types de décomposition Décomposition fonctionnelle Décomposition orientée objet

Décomposition fonctionnelle Le système est décomposé en modules Chaque module est une fonction importante dans

le domaine d'application Les modules peuvent être décomposées en

modules plus petits.

Page 11: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Decomposition (cont’d) Décomposition orientée objet

Le système est décomposé en classes (“objects”) Chaque classe est une entité majeur dans le

domaine d'application Les classes peuvent être décomposés en plus petites

classes

Décomposition orientée objet vs fonctionnel

Quelle décomposition est la bonne?

Page 12: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Décomposition fonctionnelleTop Level functions

Level 1 functions

Level 2 functions

Machine instructions

System Function

Load R10 Add R1, R10

Read Input Transform ProduceOutput

Transform ProduceOutputRead Input

Page 13: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Décomposition fonctionnelle La fonctionnalité est répartie sur tout le système Il faut comprendre l'ensemble du système pour faire un seul

changement sur le système Conséquence:

Le code source est difficile à comprendre Le code source est complexe et impossible à maintenir L'interface utilisateur est souvent maladroite et non-intuitif.

Page 14: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Qu'est ce?

cou

Gant

manteauPoche

Cave

coude

Un Eskimo!

Page 15: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Nezoeil

Oreille

mentonBouche

cheveux

A Face!

Page 16: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

NezOeil

Oreille

mentonBouche

Cheveux

coudecou

Gant

manteauPocket

Cave

A Face!An Eskimo!

Page 17: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Identification des classes hypothèses de base :

Nous pouvons trouver les classes pour un nouveau système logiciel : Ingéniérie à partir de zéro

Nous pouvons identifier les classes dans un système existant : Retro-ingénierie

Nous pouvons créer des interfaces basées sur les classes pour système existant : Interface Engineering.

Page 18: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

3. Hierarchie So far we got abstractions

This leads us to classes and objects “Chunks”

• Another way to deal with complexity is to provide relationships between these chunks

• One of the most important relationships is hierarchy• 2 special hierarchies

• "Part-of" hierarchy• "Is-kind-of" hierarchy.

Page 19: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

I/O Devices CPU Memory

Part-of Hierarchy (Aggregation)Computer

Cache ALU ProgramCounter

Page 20: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Is-Kind-of Hierarchy (Taxonomy)Cell

Muscle Cell Blood Cell Nerve Cell

Striate Smooth Red White Cortical Pyramidal

Page 21: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Where are we?

Three ways to deal with complexity: Abstraction, Decomposition, Hierarchy

Object-oriented decomposition is good Unfortunately, depending on the purpose of the system,

different objects can be found How can we do it right?

Start with a description of the functionality of a system Then proceed to a description of its structure

Ordering of development activities Software lifecycle

Page 22: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Concepts and Phenomena Phenomenon

An object in the world of a domain as you perceive it Examples: This lecture at 9:35, my black watch

Concept Describes the common properties of phenomena

Example: All lectures on software engineering Example: All black watches

A Concept is a 3-tuple: Name: The name distinguishes the concept from other

concepts Purpose (raison): Properties that determine if a

phenomenon is a member of a concept Members: The set of phenomena which are part of the

concept.

Page 23: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Definition Abstraction: Classification of phenomena into concepts

Definition Modeling: Development of abstractions to answer specific questions about a set of

phenomena while ignoring irrelevant details.

MembersName

Watch

Purpose

A device thatmeasures time.

Concepts, Phenomena, Abstraction and Modeling

Page 24: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Abstract Data Types & Classes Abstract data type

A type whose implementation is hidden from the rest of the system

Class: An abstraction in the context of

object-oriented languages A class encapsulates state and

behavior Example: Watch

Watch

timedate

SetDate(d)

CalculatorWatch

EnterCalcMode()InputNumber(n)

calculatorStateUnlike abstract data types, subclasses can be defined in terms of other classes using inheritance

State

BehaviorInheritance

Subclass• Example: CalculatorWatch

Superclass

Page 25: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Type and Instance Type:

An concept in the context of programming languages Name: int Purpose: integral number Members: 0, -1, 1, 2, -2,…

Instance: Member of a specific type

The type of a variable represents all possible instances of the variable

The following relationships are similar:Type <–> Variable Concept <–> PhenomenonClass <-> Object

Page 26: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Systems A system is an organized set of communicating parts

Natural system: A system whose ultimate purpose is not known Engineered system: A system which is designed and built by engineers

for a specific purpose The parts of the system can be considered as systems again

In this case we call them subsystems

Examples of engineered systems:• Airplane, watch, GPS

Examples of subsystems:• Jet engine, battery, satellite.

Examples of natural systems:• Universe, earth, ocean

Page 27: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Systems, Models and Views• A model is an abstraction describing a system or a

subsystem

System: Airplane

Models: Flight simulatorScale model

Views: Blueprint of the airplane componentsElectrical wiring diagram, Fuel systemSound wave created by airplane

• A view depicts selected aspects of a model

• A notation is a set of graphical or textual rules for depicting models and views:

• formal notations, “napkin designs”

Page 28: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Systems, Models and Views

System View*

Model*

Depicted byDescribed by

Airplane:System

Scale Model:Model Flight Simulator:Model

Fuel System:View

Electrical Wiring:View

Blueprints: View

(UML Notation)Class Diagram

Object Diagram

Page 29: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Models and Views(Modeleur UML)

Page 30: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Model-Driven Development1. Build a platform-independent model of an

applications functionality and behaviora) Describe model in modeling notation (UML)b) Convert model into platform-specific model

2. Generate executable from platform-specific model Advantages:

Code is generated from model (“mostly”) Portability and interoperability

Model Driven Architecture effort: http://www.omg.org/mda/

OMG: Object Management Group

Page 31: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Application vs Solution Domain Application Domain (Analysis):

The environment in which the system is operating

Solution Domain (Design, Implementation): The technologies used to build the system

Both domains contain abstractions that we can use for the construction of the system model.

Page 32: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Object-oriented Modeling

Application Domain (Phenomena)

Solution Domain (Phenomena)

System Model (Concepts) System Model (Concepts)

Aircraft TrafficController

FlightPlanAirport

MapDisplay

FlightPlanDatabase

SummaryDisplay

TrafficControl

TrafficControl

UML Package

(Analysis) (Design)

Page 33: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system
Page 34: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

What is UML? UML (Unified Modeling Language)

Nonproprietary standard for modeling software systems, OMG

Convergence of notations used in object-oriented methods OMT (James Rumbaugh and collegues) Booch (Grady Booch) OOSE (Ivar Jacobson)

Current Version: UML 2.5 Information at the OMG portal http://www.uml.org/

Commercial tools: Rational – RSA (IBM),Together (Borland), Visual Architect (business processes, BCD)

Open Source tools: ArgoUML, Omondo, Papyrus

Page 35: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

What is UML? UML (Unified Modeling Language)

Nonproprietary standard for modeling software systems, OMG Convergence of notations used in object-oriented methods

OMT (James Rumbaugh and collegues) Booch (Grady Booch) OOSE (Ivar Jacobson)

Current Version: UML 2.2 Information at the OMG portal http://www.uml.org/

Commercial tools: Rational (IBM),Together (Borland), Visual Architect (business processes, BCD)

Open Source tools: ArgoUML, StarUML, Umbrello

Commercial and Opensource: PoseidonUML (Gentleware)

Page 36: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML: First Pass You can solve 80% of the modeling problems by using

20 % UML We teach you those 20% 80-20 rule: Pareto principle

Vilfredo Pareto, 1848-1923Introduced the concept of Pareto Efficiency, Founder of the field of microeconomics.

Page 37: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML First Pass Use case diagrams

Describe the functional behavior of the system as seen by the user

Class diagrams Describe the static structure of the system: Objects,

attributes, associations Sequence diagrams

Describe the dynamic behavior between objects of the system

Statechart diagrams Describe the dynamic behavior of an individual object

Activity diagrams Describe the dynamic behavior of a system, in particular

the workflow.

Page 38: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML Core Conventions All UML Diagrams denote graphs of nodes and edges

Nodes are entities and drawn as rectangles or ovals Rectangles denote classes or instances Ovals denote functions

• Names of Classes are not underlined• SimpleWatch• Firefighter

• Names of Instances are underlined• myWatch:SimpleWatch• Joe:Firefighter

• An edge between two nodes denotes a relationship between the corresponding entities

Page 39: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML first pass: Use case diagrams

Use case diagrams represent the functionality of the systemfrom user’s point of view

Actor.

Use Case

System boundary

Classifier

Page 40: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML first pass: Class diagrams

Class

Association

Multiplicity

Class diagrams represent the structure of the system

21 1

11

11

2

SimpleWatch

Display Battery TimePushButton

Page 41: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML first pass: Class diagrams

12

push()release()

1

1

blinkIdxblinkSeconds()blinkMinutes()blinkHours()stopBlinking()referesh()

LCDDisplay BatteryLoad

1

2

1

TimeNow

1

Watch

Operations

statePushButton

Attribute

Class diagrams represent the structure of the system

Class

Association

Multiplicity

Page 42: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Message

UML first pass: Sequence diagram

:Time:Watch:WatchUser

Object

Activation

Sequence diagrams represent the behavior of a system as messages (“interactions”) between different objects

Actor

pressButton1()

Lifeline

blinkHours()

pressButton2()incrementMinutes()

:LCDDisplay

pressButton1and2()commitNewTime()

stopBlinking()

refresh()

pressButton1()blinkMinutes()

Page 43: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Statechart diagrams

State

Initial state

Final state

Transition

Event

Represent behavior of a single object with interesting dynamic behavior.

button1&2Pressed

button1Pressed

button2Pressed

button2Pressed

button2Pressed

button1Pressed

button1&2Pressed IncrementMinutes

IncrementHours

BlinkHours

BlinkSeconds

BlinkMinutes

IncrementSeconds

StopBlinking

Page 44: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Other UML NotationsUML provides many other notations, for example Deployment diagrams for modeling configurations

Useful for testing and for release management We introduce these and other notations as we go along

in the lectures OCL: A language for constraining UML models.

Page 45: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

What should be done first? Coding or Modeling?

It depends…. Forward Engineering

Creation of code from a model Start with modeling Greenfield projects

Reverse Engineering Creation of a model from existing code Interface or reengineering projects

Roundtrip Engineering Move constantly between forward and reverse engineering Reengineering projects Useful when requirements, technology and schedule are

changing frequently.

Page 46: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

UML Basic Notation Summary UML provides a wide variety of notations for modeling

many aspects of software systems Today we concentrated on a few notations:

Functional model: Use case diagram Object model: Class diagram Dynamic model: Sequence diagrams, statechart.

Page 47: Chapter 2, Modeling with UML, Part 1 -  · ArgoUML, StarUML, Umbrello ... 1. Watch. Operations. state. PushButton. Attribute. Class diagrams represent the structure of the system

Que faire ensuite ? Lire les lectures obligatoire et conseillée

Obligatoire : Bruegge&Dutoit, Object-Oriented Software EngineeringChap 4 - 4.1, 4.2, 4.3, 4.4, 4.5.3

Conseillée : Chapter 1 Bruegge&DutoitChap 4 - 4.6

Visiter le portail de COA