uml modeling and profiling lab - advanced software engineering course 2014/2015

64
UML Modeling and Profiling Lab (Advanced Software Engineering course) a.y. 2014/2015 Luca Berardinelli Post Doc @ DISIM University of L’Aquila

Upload: luca-berardinelli

Post on 20-Jun-2015

198 views

Category:

Education


2 download

DESCRIPTION

Slides for the UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

TRANSCRIPT

Page 1: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

UML Modeling and Profiling Lab

(Advanced Software Engineering course)a.y. 2014/2015

Luca BerardinelliPost Doc @ DISIM

University of L’Aquila

Page 2: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Copyright Notice

The material in these slides may be freely reproduced and distributed, partially or totally, as far as an explicit reference or acknowledge to the material author is preserved.

Page 3: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Lecturer

Page 4: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Note• Next Lesson: SOA, Monday at 11.00 in A.1.6• Check the website

Page 5: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Metamodeling, what we did

Reqs Specs Design Implementation Deployment Runtime

Problem domain Solution domain (sw)

MMMMMMMM

MMMM

Raise the abstraction level

MMMMMM MM

MMMM

Main.java

MMMMMM

Main.class>java Main.jarMain.jar

Main.warMyModel.lib

Designer

model(s)<<creates>>

languages(s)

<<specified in>>

<<read by>>

Model Editor,Model Transformations

<<creates>>

<<specified using>>

Eclipse EMF,Eclipse RCP

<<read by>>

Other Stakeholders (e.g., colleagues)

diagrams help!

diagrams ignored!

Page 6: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Reqs Specs Design Implementation Deployment Runtime

Problem domain Solution domain (sw)

MMMMMMMM

MMMM

Raise the abstraction level

MMMMMM MM

MMMM

Main.java

MMMMMM

Main.class>java Main.jarMain.jar

Main.warMyModel.mylang

Metamodeling, what we did

no diagrams(see Eclipse GMF)

Designer

<<creates>>

<<specified in>>

<<read by>>

Model Editor,Model Transformations

<<creates>>

<<specified using>>

Eclipse EMF,Eclipse RCP

Page 7: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

UML Modeling: setting the context

Reqs Specs Design Implementation Deployment Runtime

Problem domain Solution domain (sw)

MMMMMMMM

MMMM

Raise the abstraction level

MMMMMM MM

MMMM

Main.java

MMMMMM

Main.class>java Main.jarMain.jar

Main.warMyModel.uml

Designer

UML model(s)<<creates>>

UML

<<specified in>>

<<read by>>Model Editor(MagicDraw)

<<reuses>>

<<read by>>

Other Stakeholders (e.g., colleagues)

diagrams help!

Page 8: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

UML Profiling: setting the context

Reqs Specs Design Implementation Deployment Runtime

Problem domain Solution domain (sw)

MMMMMMMM

MMMM

Raise the abstraction level

MMMMMM MM

MMMM

Main.java

MMMMMM

Main.class>java Main.jarMain.jar

Main.warMyModel.uml

Designer

UML model(s)<<creates>>

UML

<<specified in>>

<<read by>>Model Editor(MagicDraw)

<<reuses>>

<<created using>>

<<read by>>

Other Stakeholders (e.g., colleagues)

diagrams help!

<<extends>>Profile(s)

<<annotated with>>

Page 9: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Main Concepts Explained

Introduction: • UML stands for “Unified Modeling Language”

• It is a industry-standard graphical language for specifying, visualizing, constructing, and documenting the artifacts of software systems

• The UML uses mostly graphical notations to express the OO analysis and design of software projects. 

• Simplifies (?) the complex process of software design

Page 10: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

UML is not (only) a set of diagrams

Page 11: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language

Reality level Reality level (M0)(e.g., sw, hw of RTES)

UML MetaModel (M2)(a.k.a., abstract syntax)

UML Model Level (M1)

usingi) XML-based artifacts,ii) Diagrams (a.k.a. concrete syntax)

yesterday

M0

M1

M2

lib.ecore

univaqlibrary.lib

uml.ecore

univaqlibrary.uml

Page 12: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language

Reality level (e.g., sw, hw of RTES)

UML Metamodel(M2)

UML Model (M1)

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

PROFILESextend by refining extend by refining

Page 13: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language

• How to model a System in UML? Where should I start?

Reality level (e.g., sw, hw of RTES)

UML Model (M1)

Generic Modeling Workflow1. modeling use cases2. modeling system structure

• software architecture• hardware architecture

3. modeling system behavior• software behavior• hardware behavior

UML MetaModel (M2)

Page 14: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language

• How to model a System in UML? Where should I start?

UML Model (M1)

Another Modeling Workflow1. modeling use cases2. modeling system behavior

• software behavior• hardware behavior

3. modeling system structure• software architecture• hardware architecture

UML MetaModel (M2)

Reality(M0)

Page 15: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language + Profiles

UML Model (M1)

21 3 4Use Case

Diagram(s)

Class Diagram(s) for Sw

State Machine Diagram(s)

for Sw

5Activity

Diagram(s)for Sw

Sequence Diagram(s)for Sw / Hw

MyProfile+

Deployment Diagram(s)

for Hw

6

UML MetaModel (M2)

Reality(M0)

Page 16: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Unified Modeling Language + Profiles

UML Model (M1)

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

PROFILESextend by refining extend by refining

2

3 1

4

5

6

Reality(M0)

UML MetaModel (M2)

Page 17: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

UML Model (M1)21 3 4 5 6

UML MetaModel (M2)

Page 18: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

UML Model (M1)21 3 4 5 6

• Identifying the system boundaries, • Identifying inputs/output from/to the external environment• Identifying the main system functionalities and their

relationships with external actors and among functionalities (extends, includes)

Page 19: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

UML Model (M1)21 3 4 5 6

CHAPTER 16

USE CASES1

A UseCase is the specification of a set of actions performed by a system (i.e., the IPS), which yields an observable result that is, typically, of value for one or more actors or other stakeholders of the system.

UseCase

Actor

An Actor models a type of role played by an entity that interacts with the subject (i.e. the IPS) (e.g., by exchanging signals and data), but which is external to the subject (i.e., in the sense that an instance of an actor is not a part of the instance of its corresponding subject). Actors may represent roles played by human users, external hardware, or other subjects.

Page 20: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

UML Model (M1)21 3 4 5 6

CHAPTER 16

USE CASES1

UseCase

Actor

Page 21: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

UML Model (M1)

USE CASES1

Page 22: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 1, Use Cases

UML Model (M1)

USE CASES1

Create Use Case Diagrams with MagicDraw

Page 23: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

UML Model (M1)21 3 4 5 6

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

Page 24: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes• Identifying the main constituent elements of your system• Determining their relationships

o Associationo Composition o Generalization

• Determining their multiplicities at run time (how many objects?)o 0..1 (optional)o 1 (required)o 0..N (optional, multiple)o 1..N (required, multiple)

UML Model (M1)21 3 4 5 6

Page 25: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

CLASSES2

UML Model (M1)21 3 4 5 6

A Class describes a set of objects that share the same specifications of features, constraints, and semantics. Class is a kind of classifier whose features are Properties and Operations. Property are owned by the class. Some of these Properties may represent the navigable ends of binary Associations.

Class

PropertyA Property is a StructuralFeature. A Property can be an owned attribute or association end. It relates an instance of the class to a value or collection of values of the type of the attribute. ...

Page 26: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

UML Model (M1)

CLASSES2

Class Diagram Composite Structure Diagram

Closely related diagrams

It allows to display "containement"

Page 27: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

CLASSES2

UML Model (M1)21 3 4 5 6

An InstanceSpecification is a model element that represents an instance in a modeled system. For example, an instance specification of a Class describes an object of that class, while an instance of an Association describes a link

Class

PropertyA Slot specifies that an Instance Specification has a value or values for its Property.

Instance Specification

Slot

Page 28: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

UML Model (M1)

CLASSES2

Class

Class

Class -> Car, WheelInstanceSpecfications: usually all the boxes with underlined names

link

link

Page 29: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 2, Classes

UML Model (M1)

CLASSES2

Create Class Diagram with Magicdraw

Page 30: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

UML Model (M1)21 3 4 5 6

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

Page 31: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments• The Deployments package specifies a set of constructs that

can be used to define the execution architecture of systems that represent the assignment of software artifacts to nodes..

• Identifying the main constituent elements (nodes) of a hardware platform, hosting the execution of software elements

• Determining their multiplicities of hardware elementso 0..1 (optional)o 1 (required)o 0..N (optional, multiple)o 1..N (required, multiple)

UML Model (M1)21 3 4 5 6

Page 32: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

DEPLOYMENTS3

UML Model (M1)21 3 4 5 6

A Node is computational resource upon which Artifacts may be deployed for execution. Nodes can be interconnected through Communication Paths to define network structures.

Node

Artifact

An Artifact is the specification of a physical piece of information that is used or produced by a software development process, or by deployment and operation of a system. Examples of artifacts include model files, source files, scripts, and binary executable files, a table in a database system, a development deliverable, or a word-processing document, a mail message.

Page 33: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

DEPLOYMENTS3

UML Model (M1)21 3 4 5 6

Node

Artifact

Page 34: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

UML Model (M1)

DEPLOYMENTS3

Page 35: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

DEPLOYMENTS3

UML Model (M1)21 3 4 5 6

Node

Communication Path

An InstanceSpecification is a model element that represents an instance in a modeled system. For example, an instance specification of a Class describes an object of that class, while an instance of an Association describes a link

A Slot specifies that an Instance Specification has a value or values for its Property.

Instance Specification

Link

Page 36: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

UML Model (M1)

DEPLOYMENTS3

Link

Page 37: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 3, Deployments

UML Model (M1)

DEPLOYMENTS3

Create Deployment Diagrams with MagicDraw

Page 38: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines

UML Model (M1)21 3 4 5 6

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

Page 39: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines• The StateMachines unit defines a set of concepts that can be

used for modeling discrete behavior through finite state-transition systems.

• State machines can be used to specify behavior of various model elements. For example, they can be used to model the behavior of individual entities.

UML Model (M1)21 3 4 5 6

Page 40: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines

STATE MACHINES4

UML Model (M1)21 3 4 5 6

A State models a situation during which some invariant condition holds. The invariant may represent a static situation such as an object waiting for some external event to occur. However, it can also model dynamic conditions such as the process of performing some behavior (e.g., running, waiting).

State

TransitionA Transition is a directed relationship between a source State and a target State. It [...] takes the state machine from one state configuration to another, representing the complete response of the state machine to an occurrence of an event of a particular type.

Page 41: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines

STATE MACHINES4

UML Model (M1)21 3 4 5 6

State

Transition

Page 42: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines

UML Model (M1)

STATE MACHINES

4

SwProcess

Signal Event: admitted, interrupt, exit...

Page 43: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 4, StateMachines

UML Model (M1)

STATE MACHINES

4

Create State Machine Diagrams with MagicDraw

Page 44: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

UML Model (M1)21 3 4 5 6

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

Page 45: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities• An activity in Unified Modeling Language (UML) is a major

task that must take place in order to fulfill an operation contract. Activities can be represented in activity diagrams

• An activity can represent:o The invocation of an operation.o A step in a business process.o An entire business process.

• Activities can be decomposed into sub activities, until at the bottom we find atomic actions.

UML Model (M1)21 3 4 5 6

[cit. Wikipedia]

Page 46: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

ACTIVITIES5

UML Model (M1)21 3 4 5 6

An Action is a named element that is the fundamental unit of executable functionality. The execution of an action represents some transformation or processing in the modeled system

Action

Control Flow

A ControlFlow is an edge that starts an activity node after the previous one is finished.

Page 47: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

UML Model (M1)21 3 4 5 6

ACTIVITIES5

Action

Control Flow

Page 48: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

UML Model (M1)

ACTIVITIES5

control flow

object flow

pin

action

Page 49: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

UML Model (M1)

ACTIVITIES5

Activity as Operation Behavior Specification

Page 50: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 5, Activities

UML Model (M1)

Create Activity Diagrams with MagicDraw

ACTIVITIES5

Page 51: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions

UML Model (M1)21 3 4 5 6

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

CHAPTER 16

Page 52: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions• Interactions can be used for several purposes including

o modeling the exchange of messages across different objects

o tracking /visualizing the execution of a System in terms of invoked operations

UML Model (M1)21 3 4 5 6

Page 53: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions

INTERACTIONS6

UML Model (M1)21 3 4 5 6

A Lifeline represents an individual participant in the Interaction. [...]Lifelines represent only one interacting entity.Lifeline

Message

A Message defines a particular communication between Lifelines of an Interaction. A communication can be, for example, raising a signal, invoking an Operation, creating or destroying an Instance. The Message specifies also the sender and the receiver. A Message associates normally two executions - one sending and one receiving.

Page 54: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions

INTERACTIONS6

UML Model (M1)21 3 4 5 6

Lifeline

Message

Page 55: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions

UML Model (M1)

INTERACTIONS6

C1

C2

+foo(x)

C3

C2

+doit(z)

____ ____ ____

Page 56: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Step 6, Interactions

UML Model (M1)

INTERACTIONS6

Create Sequence Diagram with MagicDraw

Page 57: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Profiling

UML Model (M1)

COMPONENTS

CLASSES

COMPOSITE STRUCTURES

DEPLOYMENTS

ACTIONS ACTIVITIES

COMMON BEHAVIORS

INTERACTIONS STATE MACHINES

USE CASES

Structural concepts Behavioral concepts

PROFILESextends by refining extends by refining

2

3 1

4

5

6

21 3 4 5 6

Page 58: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Why I need a profile

Reqs Specs Design Implementation Deployment Runtime

Problem domain Solution domain (sw)

MMMMMMMM

MMMM

Raise the abstraction level

MMMMMM MM

MMMM

Main.java

MMMMMM

Main.class>java Main.jarMain.jar

Main.warMyModel.uml

Documentation

m2m transformation

browser

MMMMMM

docs.html

Annotations on models (M1) using stereotypes and their properties are similar to "structured comments" in programming languages. You can add them to enable additional activity and remove them without "corrupting" the structure and behavioral specification of a UML model

Page 59: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

CLASSES

Profiling• Extending the UML Language for domain-specific purposes• Only extension by refinement• Any concept in the UML Language can be refined• Concepts cannot be deleted or modified

Class

UML Model (M1)21 3 4 5 6

MY PROFILE

stereotype

1..*STATEMACHINES

State

CLASSES

ClassSTATEMACHINES

State

Defining a Profile

Page 60: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Profiling

CLASSESA Class describes a set of objects that share the same specifications of features, constraints, and semantics. Class is a kind of classifier whose features are Properties and Operations. Property are owned by the class. Some of these Properties may represent the navigable ends of binary Associations.

Class

My Profile For HTML Docs

stereotype<<HTML>>

The stereotype <<HTML>> is applied to (and only to!) Class model elements that has to be documented through HTML-based document [...]

UML Model (M1)21 3 4 5 6

Defining a Profile

Page 61: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Profiling

UML Model (M1)

Class stereotype<<HTML>>

<<HTML>><<HTML>>

<<HTML>>

<<HTML>>

<<HTML>>

<<HTML>>

2

Defining a Profile

Applying a Profile

Page 62: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Profiling

UML Model (M1)

1) Define and 2) Apply a new Profile

MyProfileDefining a Profile

Applying a Profile

Page 63: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

Artifacts from annotated UML Models

UML Model (M1)

model transformation(s)

Analysis Model

Code

Docs

Page 64: UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015

References• UML2: http://www.uml.org/

o You should download and read the lastest Superstructure Specificationo You can also find tutorials and books online explaining UML for beginners.

• MagicDraw® : http://www.magicdraw.com/o You can find video tutorial on the web siteo Existing profiles are in <install.root>/profiles/o <install.root>/manuals/ for additional documentation about MagicDraw® and its

capabilities