UML and Objectorientation. Kristian Sandahl

Similar documents
Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

Design Patterns. Observer Pattern*

Design Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Dr. Xiaolin Hu. Review of last class

Chapter 8, Object Design: Reusing Pattern Solutions

COSC 3351 Software Design. Design Patterns Behavioral Patterns (I)

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts

Object-Oriented Design

CSC207H: Software Design Lecture 6

Chapter 18. Software Reuse

Refining the Observer Pattern: The Middle Observer Pattern

Design Patterns V Structural Design Patterns, 2

Design Patterns Reid Holmes

Unified Modeling Language (UML) Class Diagram

Object-Oriented Oriented Programming

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

SDC Design patterns GoF

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Model-based Software Engineering (02341, spring 2016) Ekkart Kindler

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

Design Patterns. An introduction

Object-Oriented Design

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

LABORATORY 1 REVISION

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

18.1 Definitions and General OO Principles

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Object-Oriented Design

Software Service Engineering

Design issues: abstraction and patterns Strategy Pattern Singleton Pattern. CSIE Department, NTUT Woei-Kae Chen

Design Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern.

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Course UML and Design Patterns of module Software Engineering and Design, version November 18, 2013.

Course "UML and Design Patterns" of module "Software Engineering and Design", version November 2011

Observer Pattern. CS580 Advanced Software Engineering October 31, Yu Sun, Ph.D.

An Introduction to Patterns

Object-Oriented Systems Analysis and Design Using UML

Design patterns. Jef De Smedt Beta VZW

Topics in Object-Oriented Design Patterns

administrivia today UML start design patterns Tuesday, September 28, 2010

Component ConcreateComponent Decorator ConcreateDecoratorA ConcreteDecoratorB

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Material and some slide content from: - GoF Design Patterns Book. Design Patterns #1. Reid Holmes. Lecture 11 - Tuesday October

Lecture 20: Design Patterns II

Information systems modelling UML and service description languages

May Comp-B 11, Advanced Software Design. 3 hours duration

Design Patterns. GoF design patterns catalog

Object Oriented Design and Programming Revision

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Chapter 2: The Object-Oriented Design Process

Design Patterns Reid Holmes

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

Introducing the UML Eng. Mohammed T. Abo Alroos

CPSC 427a: Object-Oriented Programming

Object-Oriented Systems Development: Using the Unified Modeling Language

Tuesday, October 4. Announcements

Lecture 19: Introduction to Design Patterns

Object-Oriented Design

Introduction to Unified Modelling Language (UML)

Brief Note on Design Pattern

Design Patterns. Softwaretechnik. Matthias Keil. Albert-Ludwigs-Universität Freiburg

Development and Implementation of Workshop Management System Application to Explore Combing Multiple Design Patterns

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

SOFTWARE PATTERNS. Joseph Bonello

Object Oriented Analysis and Design - Part2(Design)

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Object Oriented Paradigm

INTERNAL ASSESSMENT TEST III Answer Schema

CAS 703 Software Design

Using Design Patterns in Java Application Development

Chapter 7 Design and Implementation

Object- Oriented Design with UML and Java Part I: Fundamentals

Outline. Design Patterns. Observer Pattern. Definitions & Classifications

Design Patterns Design patterns advantages:

Introduction and History

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

Adapter & Facade. CS356 Object-Oriented Design and Programming November 19, 2014

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

UNIT V *********************************************************************************************

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Introduction to OO Concepts

Page 1. Chapter 8, Object Design: Design Patterns II. Recall: Why reusable Designs? Definitions. A Taxonomy of Design Patterns

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS

What s Next. INF 117 Project in Software Engineering. Lecture Notes -Spring Quarter, Michele Rousseau Set 6 System Architecture, UML

Design Patterns Application with MDE

Transcription:

UML and Objectorientation Kristian Sandahl

2 Maintenance Requirements Validate Requirements, Verify Specification cceptance Test (Release testing) System Design (rchitecture, High-level Design) Verify System Design System Testing (Integration testing of modules) Module Design (Program Design, Detailed Design) Verify Module Design Verify Implementation Module Testing (Integration testing of units) Implementation of Units (classes, procedures, functions) Unit testing Project Management, Software Quality ssurance (SQ), Supporting Tools, Education

3 The goals of module design Provide the expected function Prepare for change: Separation of concern Testability Understandability Contribute to quality, eg: Performance Usability Reliability... Map for the implementers and testers

4 Modelling software Models supplement natural language Models support both elicitation and design The boundaries between specification and design have to be decided There are high transition costs from functional to object-oriented models UML has become the standard notation Industry interest in SySML (watch out in the future)

5 Single Class Class name attributes operations visibility + public - private # protected ~ package Customer name: String[1] email: String [0..2] +getnooforders():integer +getorderstatus():string + addemail(email:string) Parameter Return type Multiplicity 1 exactly one 0..1 Zero or one * Zero or more (same as 0..*) 2..8 etween 2 and 8

Relationships (1/6) - overview and intuition - ssociation 6 ssociation (with navigability)

Relationships (1/6) - overview and intuition - ssociation attributes ooktitle + neworderdate: Date [0..1] + islatestedition: oolean [1] + items: ookitem[*] oth representations are almost equivalent 7 role name Date + neworderdate 0..1 * ooktitle * + islatestedition 1 oolean 1 directed association * ookitem + items {ordered} {ordered} {unordered} {unique}{nonunique} Default is unordered, unique

class UML-OO/Kristian Sandahl Relationships (1/6) - overview and intuition - ssociation 4 Car Wheel 8 Explicitly show that navigation is not allowed Navigation - mycar can reach the wheels, but not the opposite objects wheel1 mycar wheel2 wheel4 mycar has links to 4 wheels wheel3

Relationships (1/6) - overview and intuition - ssociation Car 4 Wheel 9 What does it mean to have a * here? What if we have multiplicity 1 instead? "*" "1" mycar1 mycar2 mycar3 wheel can only be liked to one car instance mycar1 mycar2 wheel1 wheel2 wheel3 wheel4 wheel can be linked to more than one car instance wheel1 wheel2 wheel3 wheel4

Relationships (1/6) - overview and intuition - ssociation Car 4 Wheel 10 ssociations are the "glue" that ties a system together association instance = link mycar1 n association describes a relation between objects at run-time. wheel1 wheel2 wheel3 wheel4 {(mycar1,wheel1), (mycar1,wheel2), (mycar1,wheel3), (mycar1,wheel4)}

11 Relationships (2/6) - overview and intuition - ggregation ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation

Relationships (2/6) - overview and intuition - ggregation Common vague interpretations: "owns a" or "part of" 12 Car 4 Wheel What does this mean? What is the difference to association? Vague definitions Inconsistency and misunderstandings ggregation was added to UML with little semantics. Why? Jim Rumbaugh "Think of it as a modeling placebo" Recommendation: - Do not use it in your models. - If you see it in other's models, ask them what they actually mean.

Relationships (3/6) - overview and intuition - Composition 13 ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation void it to avoid misunderstandings Composition

Relationships (3/6) - overview and intuition - Composition Car 1 4 Wheel 14 ny difference to association? Yes! First, multiplicity must be 1 or 0..1. n instance can only have one owner. ut, isn't this equivalent to what we showed with associations? Car 1 4 Wheel mycar1 mycar2 Well, in this case... wheel1 wheel2 wheel3 wheel4

Relationships (3/6) - overview and intuition - Composition Using composition... 15 1 4 2 1 Car Wheel MotorCycle Ok for wheels to be part of mycar1 or mybike1 mycar1 mybike1 wheel1 wheel2 wheel3 wheel4 wheel5 wheel6

Relationships (3/6) - overview and intuition - Composition Using composition... 1 4 2 1 Car Wheel MotorCycle 16 mycar1 Can mycar1 and mybike1 share the same wheels? NO! Not with composition! mybike1 wheel1 wheel2 wheel3 wheel4 Key concepts "No sharing" rule The owner is responsible for managing its parts, wheel5e.g. wheel6 allocation and deallocation.

Relationships (3/6) - overview and intuition - Composition Using associations... (Note the difference. The diamond is removed.) Car Wheel MotorCycle 4 1 2 1 17 Can mycar1 and mybike1 share the same wheels this time? mycar1 Yes! ssociations do not have a "no sharing" rule. mybike1 However, in this case it is a strange model... wheel1 wheel2 wheel3 wheel4 wheel5 wheel6

18 Relationships (4/6) - overview and intuition - Generalization ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation void it to avoid misunderstandings Composition n instance of "" is part of an instance of "", where the former is not allowed to be shared. Generalization

Relationships - (4/6) overview and intuition - Generalization Class with code for the drive() operation 1. Inheritance ~ relation implementation Vehicle + drive() Vehicle + drive() Car + reverse() Vehicle + drive() 19 Visible Type: Vehicle. Instance of: MotorCycle. Can we drive()? Can we reverse()? Visible Type: Car. Instance of: Car Can we drive()? Can we reverse()? Visible Type: Vehicle. Instance of: Car Can we drive()? Can we reverse()? Car Overrides drive() MotorCycle n instance of a class can have many types = (subtyping) polymorphism + reverse() Inherits the code for drive(). New operation reverse() + drive() 2. Subtyping ~ relation on interfaces static typing: safe substitution

Relationships - (5/6) overview and intuition - Realization 20 ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation void it to avoid misunderstandings Composition n instance of "" is part of an instance of "", where the former is not allowed to be shared. Generalization 1) "" inherits all properties and operations of "". 2) n instance of "" can be used where a instance of "" is expected. Realization

Relationships - (5/6) overview and intuition - Realization 21 <<interface>> Door + open() Vehicle + drive() Specifier Realization Can we create an instance of Vehicle? Vehicle + drive() Interface (no implementation) Car Implementation MotorCycle Can we create an instance of nothervehicle? + drive() reverse() + reverse() Correct? + open() Provides the Door interface + drive() Must implement the interface bstract class (Italic) bstract operation nothervehicle + drive() + open()

Relationships - (5/6) overview and intuition - Realization What is the difference between an interface and an abstract class? 22 <<interface>> Door + open() Interface nothervehicle + drive() + open() bstract class Cannot contain implementation Non of them can be instantiated Can (but need not to) contain implementation n abstract class with only abstract operations is conceptually the same as an interface

Relationships - (6/6) overview and intuition - Realization 23 ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation void it to avoid misunderstandings Composition n instance of "" is part of an instance of "", where the former is not allowed to be shared. Generalization 1) "" inherits all properties and operations of "". 2) n instance of "" can be used where a instance of "" is expected. Realization "" provides an implementation of the interface specified by "". Dependency

Relationships - (6/6) overview and intuition - Dependency 24 Schedule viewer Lecture client Dependency supplier <<use>>

Relationships - overview and intuition 25 ssociation (with navigability) "" has a reference(s) to instance(s) of "". lternative: attributes ggregation void it to avoid misunderstandings Composition n instance of "" is part of an instance of "", where the former is not allowed to be shared. Generalization 1) "" inherits all properties and operations of "". 2) n instance of "" can be used where a instance of "" is expected. Realization "" provides an implementation of the interface specified by "". Dependency "" is dependent on "" if changes in the definition of "" causes changes of "".

26 Software Design Patterns Design Pattern is a standard solution for a standard design problem in a certain context. Goal: reuse design information

Example: Facade 27

Example: Facade 28 Facade

29 How to describe design patterns? GoF book

30 Facade Intent Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. Motivation Structuring a system into subsystems helps reduce complexity. common design goal is to minimize the communication and dependencies between subsystems. example

31 Facade pplicability Use the Facade pattern when: you want to provide a simple interface to a complex subsystem. This makes subsystems more reusable and easier to customize. there are many dependencies between clients and the implementation classes of an abstraction. Introduce a facade to decouple the subsystem from other subsystems, thereby promoting subsystem independence and portability. you want to layer your subsystems. Use a facade to define an entry point to each subsystem level.

32 Facade Consequences The Facade pattern offers the following benefits: 1. It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and making subsystem easier to use. 2. It promotes weak coupling between subsystem and its clients. Weak coupling lets you vary the components of the subsystem without affecting its clients. 3. It doesn't prevent applications from using subsystem classes if they need to.

33 Facade Structure Participants Collaborations Implementation Sample Code Known Uses Related Patterns

Observer 34 50% 50% 40% 30% 20% 10% 0% a b c 40% 30% 20% 10% 0% a b c a = 10% b = 30% c = 40%

35 Observer pplicability When an abstraction has two aspects, one dependent on the other. When a change to one object requires changing others. When an object should be able to notify other objects without making assumptions about who these objects are.

Observer, structure Subject Stock Investor 36 Observer attach(observer) detach(observer) notify() * update() IM subjectstate getstate() setstate() Goldman Sachs observerstate update() ConcreteSubject ConcreteObserver

Observer, collaborations 37

38 Observer, consequences bstract coupling between Subject and Observer Support for broadcast communication Unexpected updates

Strategy Name: Strategy lso known as: Policy Problem: Need to use different variants of the same algorithm in a class Different algorithms will be appropriate at different time. It is hard to add new algorithms and to change existing ones. 39 Example: Input (Plain Text) Cryptographic Module lgorithms: DES ES Output 3DES Intent (from GoF): (cipher text) "Define a family of algorithms, encapsulate each one and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it." RC5

Strategy Structure: Reference to a strategy type bstract 40 Context +contextinterface() -strategy * Strategy +algorithminterface() In example: e.g. class Encryptlg In example: Part of crypto module. Holds data, keys etc. ConcreteStrategy +algorithminterface() ConcreteStrategy +algorithminterface() ConcreteStrategyC +algorithminterface() In Example: Implements e.g. algorithm ES E.g. lgdes E.g. lgrc5

41 Strategy Suppose we add a new strategy: Storage media: Disc US-stick DVD Cloud. Input (Plain Text) Cryptographic Module Output (Cipher text on media)

Two strategies 42 ackup +EncryptInt () +StoreInt() Media +Store() Disc DVD Cloud Encryptlg +Store() +Store() +Store() +Encrypt() ES lgdes lgrc5 +Encrypt() +Encrypt() +Encrypt()

www.liu.se