modeling for architects i: uml · dfki - jk views and diagrams we will later in this lecture...

55
© DFKI - JK Modeling for Architects I: UML Architectural Thinking for Intelligent Systems Winter 2019/2020 Marcel Köster, Kai Waelti, Jochen Britz Prof. Dr. habil. Jana Koehler

Upload: others

Post on 18-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Modeling for Architects I:UML

Architectural Thinking for Intelligent Systems

Winter 2019/2020

Marcel Köster, Kai Waelti, Jochen BritzProf. Dr. habil. Jana Koehler

Page 2: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

References & Special Thanks

Prof. Sven Apel for his slides & material

https://www.uml-diagrams.org/ for several images

https://c4model.com/ for some images

Architectural Thinking for Intelligent Systems: UML2

Page 3: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Agenda

Capturing architectural concepts with UML 2

Basics & class diagrams (repetition)

Sequence diagrams

Package & Component diagrams

State machines

Use case diagrams

Architectural Thinking for Intelligent Systems: UML3

Page 4: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Views and Diagrams

We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions

There is no standard for the representation of views, but some modeling standards are helpful and commonly used

Context view – none ! Component view – UML package and component diagrams Distribution view – UML package and component diagrams Runtime view - UML sequence diagrams, UML state

machins, BPMN collaboration diagrams Functional requirements – UML use case diagrams

Architectural Thinking for Intelligent Systems: UML4

Page 5: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Learning Objectives

Know– purpose of UML– 14 different diagram types

Being able to– capture architectural concepts with UML 2.5.1– communicate architectural concerns and decisions using

views– explain how UML describes structures, processes and

states of software

Architectural Thinking for Intelligent Systems: UML5

Page 6: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

What is UML?

Uniform notationBooch + OMT + Use Cases (+ state charts)

UML is *not*– A method– A process

Architectural Thinking for Intelligent Systems: UML6

Page 7: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

UML (in a nutshell)

Architectural Thinking for Intelligent Systems: UML7

Page 8: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Why UML?

Architectural Thinking for Intelligent Systems: UML8

There are other modeling languages like– Systems Modeling Language SysML

• Is less software centric and a lot smaller– The Open Group’s ArchiMate

• Best for higher-level Enterprise Architectures

UML is the de-facto standard for software modeling UML fits nicely under the covers

– Describes the system from various perspectives

Page 9: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Purpose of UML

Architectural Thinking for Intelligent Systems: UML9

Provides unified notation and semantics of modeling elements

Describes structures and processes of a system

Offers possibility for different views on a system

Allows people to understand and talk about the design decisions

Page 10: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Maps of Your System

Architectural Thinking for Intelligent Systems: UML10

Use different views with different levels of detail– Tell different stories to different types of audiences

Helps to describe architecture during up-front designsessions as well as retrospectively documenting an existing code base

Page 11: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

UML 2.5 Hierarchy from Paulo Merson

Architectural Thinking for Intelligent Systems: UML11

Page 12: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

STRUCTURAL DIAGRAM TYPES

Architectural Thinking for Intelligent Systems: UML12

Page 13: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Class Diagram – building blocks of object-oriented systems

Architectural Thinking for Intelligent Systems: UML13

Page 14: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Class Diagram Focus on Behavior

Class diagrams show generic descriptions ofpossible systems

Object diagrams show particular instantiations of systems and their behavior

Attributes and operations are also collectively called features

Risk of turning into data models→ be sure to focus on behavior!

Architectural Thinking for Intelligent Systems: UML14

Page 15: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Class Diagram UML 2.5 Reference

Architectural Thinking for Intelligent Systems: UML15

Page 16: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Interfaces

Equivalent to abstract classes minus the attributes Represented as classes with explicit stereotype

«interface» or implicit lollipop notation

Architectural Thinking for Intelligent Systems: UML16

Page 17: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Objects

Class is a blueprint from which objects are created– Class: Human– Object: Man, Woman

Shown as rectangles with their name and type underlined

Architectural Thinking for Intelligent Systems: UML17

Page 18: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Associations

Architectural Thinking for Intelligent Systems: UML18

Represent structural relationships between objects Multiplicity constraints how many entities one may be

associated with

Page 19: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Aggregation → parts may be shared Composition → one part belongs to one whole

Aggregation vs. Composition

Architectural Thinking for Intelligent Systems: UML19

Page 20: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

MailOrder and BoxOfficeOrder specialize their superclass Order

Generalization

Architectural Thinking for Intelligent Systems: UML20

Page 21: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

New software often builds on old software by imitation, refinement, or combination

Similarly, classes may be extensions, specializations or combinations, of existing classes

Why Inheritance?

Architectural Thinking for Intelligent Systems: UML21

Page 22: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Generalization Expresses… Conceptual hierarchy

– conceptually related classes can be organized into a specialization hierarchy

• people, employees, managers• geometric objects

Polymorphism– objects of distinct, but related classes may be uniformly

treated by clients• array of geometric objects

Software reuse– related classes may share interfaces, data structures or

behavior• geometric objects

Architectural Thinking for Intelligent Systems: UML22

Page 23: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Component Diagram

Shows components, provided and required interfaces, ports, and relationships between them

Based on assumptions, that previously constructed components could be reused– or be replaced by some other equivalent component

Artifacts that implement the component are intended to be capable of being deployed independently– e.g. for updating an existing system

Architectural Thinking for Intelligent Systems: UML25

Page 24: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Components Could Represent…

Logical components– e.g. business components, process components, etc.

Physical components– e.g. EJB components, COM+ and .NET components,

WSDL components, etc.

A component is a replaceable part of a system that conforms to and provides the realization of a set of interfaces

Architectural Thinking for Intelligent Systems: UML26

Page 25: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

UserService Component

Component Notation

An interface is a collection of operations that specify a service that is provided by or requested from a component

Provided Interface Required Interface

Architectural Thinking for Intelligent Systems: UML27

Page 26: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Components Notation: Ports

A port is a specific window into an encapsulated component accepting messages– to and from the component

Simple Port

Architectural Thinking for Intelligent Systems: UML28

Page 27: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Components: Parts and Connectors

A part is a specification of a role that composes part of the implementation of a component

A connector is a communication relationship betweentwo parts or ports within the context of a component– Connector linking could be either delegation or

assembly connector

Architectural Thinking for Intelligent Systems: UML29

Page 28: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Connector between two or more parts or ports Defines that one or more parts provide the services that

other parts use

Assembly connector that assembles 3 parts

Components: Assembly Connectors

Architectural Thinking for Intelligent Systems: UML30

Page 29: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Components: Delegation Connector

Connector that links the external contract of a component to the realization of that behavior

Represents the forwarding of events Can be used to model hierarchical decomposition of

behavior A port may delegate to a set of ports on subordinate

components

Architectural Thinking for Intelligent Systems: UML31

Page 30: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Component Diagram: A Reference

Architectural Thinking for Intelligent Systems: UML32

Page 31: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Packages Notation

A package diagram shows structure of the designed system at level of packages

Package is a namespace used to group together elements that are semantically related and might change together– May own packageable elements like

Type, Classifier, Use Case, etc.

– Can be used as a template for other packages• Template parameters can be offered through packageable

elements

– Different directed relationships• use, import, merge

Architectural Thinking for Intelligent Systems: UML33

Page 32: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Package Diagram: A Reference

Architectural Thinking for Intelligent Systems: UML34

Page 33: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Package Diagram: Design Pattern known as Transfer Obj.

Architectural Thinking for Intelligent Systems: UML35

Page 34: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Deployment Diagram

Architectural Thinking for Intelligent Systems: UML36

Page 35: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

BEHAVIORAL DIAGRAM TYPES

Architectural Thinking for Intelligent Systems: UML37

Page 36: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Use Case Diagram

Architectural Thinking for Intelligent Systems: UML38

Page 37: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Using Use Case Diagrams

Generic description of an entire transaction involving several actors

Presents a set of use cases (ellipses) and the external actors that interact with the system

Dependencies and associations between use cases may be indicated

“A use case is a snapshot of one aspect of your system. The sum of all use cases is the external picture of your system”

Architectural Thinking for Intelligent Systems: UML39

Page 38: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Sequence Diagram

Architectural Thinking for Intelligent Systems: UML40

Page 39: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Using Sequence Diagrams

Depicts a scenario by showing the interactions among a set of objects in temporal order

Objects (not classes!) are shown in vertical bars

Events or message dispatches are shown as horizontal arrows from the sender to the receiver

Avoid returns in sequence diagrams, unless they add clarity

Architectural Thinking for Intelligent Systems: UML41

Page 40: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Asynchrony and Constraints in Sequence Diagrams

Architectural Thinking for Intelligent Systems: UML42

Page 41: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

State Diagram

Describes the temporal evolution of an object of a given class in response to interactions with other objects inside or outside the systems

Architectural Thinking for Intelligent Systems: UML43

Page 42: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

State Diagram: States and Events

A state is a period of time during which an object is waiting for an event to occur– may be nested– depicted as rounded box with (up to) three sections

• name• state variables• triggered operations

An event is a one-way asynchronous communication from one object to another– atomic (non-interruptible)– may cause object to make a transition between states

Architectural Thinking for Intelligent Systems: UML44

Page 43: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Transitions

A transition is an response to an external event received by an object in a given state

– May invoke an operation, and cause the object to change state

– May send an event to an external object– Internal transitions are part of the triggered operations of

a state– External transitions label arcs between states

Architectural Thinking for Intelligent Systems: UML45

Page 44: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Operations and Activities

Operation– Atomic action invoked by a transition

• Entry and exit operations can be associated with states

Activity– Ongoing operation that takes place while object

is in a given state• Modelled as “internal transitions” labelled with the

pseudo-event do

Architectural Thinking for Intelligent Systems: UML46

Page 45: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Nested Statechart

Architectural Thinking for Intelligent Systems: UML47

Page 46: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Concurrent Substates

Architectural Thinking for Intelligent Systems: UML48

Page 47: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Activity Diagram: Resolve an issue in software design

Architectural Thinking for Intelligent Systems: UML49

Page 48: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

USING UML

Architectural Thinking for Intelligent Systems: UML50

Page 49: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Perspectives

Conceptual– Represent domain concepts: Ignore software issues

Specification– Focus on visible interfaces and behavior: Ignore internal

implementation

Implementation– Document implementation choices: Most common, but

least useful perspective(!)

Architectural Thinking for Intelligent Systems: UML51

Page 50: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

More Than Creating Blueprints

Create Use Case diagrams to reason about the desired behavior of your system

Specify the vocabulary of your domain using class diagrams

Specify the sentences of your domain using component and package diagrams

Use sequence diagrams, statechart diagrams and activity diagrams (or BPMN) to show the way the things in your domain work together to carry out this behavior

Architectural Thinking for Intelligent Systems: UML52

Page 51: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

OUTLOOK

Architectural Thinking for Intelligent Systems: UML53

Page 52: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

UML Tools

– StarUML• Sophisticated standalone software modeler

– draw.io• Online draw app

– UMLet• Standalone or Eclipse Plugin

– yEd• Standalone graph editor

– astah UML• Lightweight UML diagramming tool

– Microsoft Visio• Diagramming and vector graphics application

Architectural Thinking for Intelligent Systems: UML54

Page 53: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Further Reading

Architectural Thinking for Intelligent Systems: UML55

Page 54: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Summary

UML 2.5 in a nutshell– The general purpose of UML– Several diagram types for different tasks– The different notations depending on the diagram– The semantics of these diagrams

Beeing able to use UML to model– Classes, Packages, States, «Control Flow» , etc.

Architectural Thinking for Intelligent Systems: UML56

Page 55: Modeling for Architects I: UML · DFKI - JK Views and Diagrams We will later in this lecture discuss views, which help us to communicate architectural concerns and decisions There

© DFKI - JK

Some Working Questions1. What was the motivation behind UML?

2. Which UML diagrams exist and what are they used for?

3. Can diagram type X be used to model thing Y in a domain?

4. How can you use diagram X to model a problem description Y(See assignment )

Architectural Thinking for Intelligent Systems: UML57