OODP OOAD Session 7a

Similar documents
Object Oriented. Analysis and Design

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

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

Object-Oriented Design

Object-Oriented Design

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

GRASP 2. CSC 440: Software Engineering Slide #1

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

GRASP Design Patterns A.A. 2018/2019

17. GRASP: Designing Objects with Responsibilities

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

Review Software Engineering October, 7, Adrian Iftene

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

State Pattern. CSIE Department, NTUT Woei-Kae Chen. State: Intent. Allow an object to alter its behavior when its internal state changes.

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

OODP Session 9. Session times PT Thursday 18:00 21:00 room: School of Pharmacy, John Hanbury Lecture Theatre FT Tuesday 13:30 17:00 room: Malet 404

CS/CE 2336 Computer Science II

Design patterns. Jef De Smedt Beta VZW

Principles of Software Construction: Objects, Design and Concurrency. Object-Oriented Design: Assigning Responsibilities.

2 GRASP Patterns and basic OO Design. Roel Wuyts OASS

Four More GRASP Principles CSSE 574: Session 5, Part 2

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

Lecture 17: Patterns Potpourri. Copyright W. Howden 1

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

Object-Oriented Design II - GRASP

An Introduction to Patterns

What is Design Patterns?

Patterns and Testing

ADVANCED SOFTWARE DESIGN LECTURE 4 GRASP. Dave Clarke

GOF Patterns Applied

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS

SDC Design patterns GoF

CSSE 374: More Object Design with Gang of Four Design Patterns

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

What is Design Patterns?

Software Design And Modeling BE 2015 (w. e. f Academic Year )

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

Design Patterns. Gunnar Gotshalks A4-1

Requirements and Design Overview

Builder Pattern Tutorial Written Date : September 28, 2009

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

The GoF Design Patterns Reference

» Reader for RTF (Rich Text Format) should be able to convert to any other representation Plain Text, MIF (Maker Interchange File), Postscript

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

GRASP ing at the First 5 Patterns Principles CSSE 574: Session 3, Part 4

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

Object-Oriented Design I - SOLID

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

Object Analysis & Design in the textbook. Introduction to GRASP: Assigning Responsibilities to Objects. Responsibility-Driven Design

Summary of the course lectures

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

Object Oriented Design and Programming Revision

Object-Oriented Design I

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

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

Design patterns. OOD Lecture 6

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

The Design Patterns Matrix From Analysis to Implementation

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

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

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

Responsibilities. Using several specific design principles to guide OO design decisions.

Lecture 20: Design Patterns II

A4 Explain how the Visitor design pattern works (4 marks)

Laboratorio di Progettazione di Sistemi Software Design Pattern Creazionali. Valentina Presutti (A-L) Riccardo Solmi (M-Z)

Tecniche di Progettazione: Design Patterns

Design Patterns Reid Holmes

VEL TECH HIGH TECH Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE UNIT 1 UML DIAGRAMS

(c) Bartosz Walter 1

Design Patterns. An introduction

CSSE 374: GRASP ing at the First Five Patterns Principles. Shawn Bohner Office: Moench Room F212 Phone: (812)

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

Iterator pattern. Acknowledgement: Eric Braude

Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt. The Builder Pattern

Creational Patterns. Factory Method (FM) Abstract Factory (AF) Singleton (SI) Prototype (PR) Builder (BU)

Information systems modelling UML and service description languages

Design Pattern Detection

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Object-Oriented Design

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

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

Foundations of Software Engineering Design Patterns -- Introduction

A Reconnaissance on Design Patterns

Design Pattern- Creational pattern 2015

Brief Note on Design Pattern

Object-Oriented Design II

ROEVER ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY CS2353-OBJECT ORIENTED ANALYSIS AND DESIGN. Unit-I. Introduction to OOAD

Design Pattern Detection

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

COMP 6471 Software Design Methodologies

Compsci 290/Mobile, Java

Tecniche di Progettazione: Design Patterns

Software Design COSC 4353/6353 D R. R A J S I N G H

Pro Objective-C Design Patterns for ios

Exam in TDDB84: Design Patterns,

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS2353-OBJECT ORIENTED ANALYSIS AND DESIGN. Unit-I. Introduction to OOAD

Tuesday, October 4. Announcements

Transcription:

OODP OOAD Session 7a Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded Visiting Hours: Tuesday 17:00 to 19:00

Advanced Patterns

Previously on OOAD Strategy Decorator Creation Patterns Factory method Abstract Factory Singleton (don t think in patterns, think patterns)

State

DriverAI We want to simulate an AI that among other things drives To make it feel human it should have moods The driving and only the driving should depend on the AI s mood One solution is to, give it a mood attribute. What is the problem with this solution? AI mood Swim () drive()

State Pattern Solution: delegate mood dependent behaviors AI mood _mood mood drive() Angry drive() Happy drive() Sad drive()

State Pattern, Consequences Easy to add more states More classes Less code State transition appears explicitly in the DCD Context request() State handle() ConcreteStateA handle() ConcreteStateB handle() ConcreteStateC handle()

State Pattern, What s Missing? Who is responsible for the state transitions? Context ConcreteState classes What are the pros and cons of each option? Context request() State handle() ConcreteStateA handle() ConcreteStateB handle() ConcreteStateC handle()

Discussion Why Use? Issues Objects behaviour depends on its state + messy code to implement this When are states created How to add more states Context request() State handle() ConcreteStateA handle() ConcreteStateB handle() ConcreteStateC handle()

Builder

Airplane Game, Domain Model Player 1 Has An 1 Airplane Fighter Airplane Passenger Airplane Transport Airplane Harrier Model Airplane Problem: Who should construct airplane If classes inheriting airplane were not composite what would GRASP patterns tell us?

Airplane Game, Domain Model Player 1 Has An 1 Airplane fly() takeoff() AirplaneFly AirplaneFly fly() Fighter Passenger Model AirplaneFly AirplaneFly AirplaneFly fly() fly() fly() Classes inheriting airplane are composite, what do GRASP patterns tell us? Cohesion Coupling Expert

Airplane Game, Delegate Player AirplaneCreator AirplaneCreator createairplane(airplaneidentity) Idea: create a class that has the expertise to build an airplane Why is this not such a good idea?

Airplane Game, Delegate,Delegate Player Director AirPlaneBuilder Director(airplaneBuilder) Director knows how to manage the airplane building The Builder knows how to build the parts

Airplane Game, Director, Builder Director Director(airplaneBuilder) buildairplane() AirPlaneBuilder buildflightcapability() buildtakeoffcapability() getairplane() HarrierBuilder buildflightcapability() buildtakeoffcapability() getairplane() Director knows how to manage the airplane building The Builder knows how to build the parts

Builder Pattern :Client Director Director(airplaneBuilder) Construct() Builder buildpart() getresult() new ConcreteBuilder :ConcreteBuilder ConcreteBuilder buildpart() getresult() new Director(ConcreteBuilder) Construct() GetResult() :Director buildparta() buildpartb() Problem: How to create a composite object Why does the client create ConcreteBuilder?

Builder Pattern Pros Isolates code for construction and representation Cons More work More classes More control over construction process

Back to GRASP

More GRASP patterns Information Expert, Creator, Low Coupling, High Cohesion, Controller Polymorphism Indirection Pure Fabrication Protected Variations

Polymorphism

Pattern Name: Polymorphism Problem It Solves: How to handle alternatives based on type? How to create pluggable software components? Solution: When related alternatives or behaviour vary by type, assign responsibilities for the behaviour using polymorphism Alternatives based on type replacing code by classes and types Pluggable software components viewing components in client server relationships, how can you replace one server component with another without affecting the client

Where have we seen Polymorphism GoF Design Patterns: Strategy Abstract Factory

Indirection

Pattern Name: Indirection Problem It Solves: Where to assign a responsibility, to avoid direct coupling between two or more things Solution: Assign the responsibility to an intermediate object

Where have we seen Indirection GoF Design Patterns: Strategy Abstract Factory

Pure Fabrication

Pattern Name: Pure Fabrication Problem It Solves: What object should have the responsibilities, when you don t want to violate high cohesion and low coupling, or other goals, but solutions offered by Expert (for example) are not appropriate. Solution: Assign a highly cohesive set of responsibilities to an artificial class that does not represent a problem domain concept (such a class is a fabrication of the imagination).

Where have we seen Pure Fabrication GoF Design Patterns: Strategy Abstract Factory

Protected Variation

Pattern Name: Protected Variation Problem It Solves: How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Solution: Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them.

Where have we seen Protected Variation GoF Design Patterns: Strategy Decorator Abstract Factory...