Assigning Responsibilities by Larman

Similar documents
References: Applying UML and patterns Craig Larman

GRASP: Patterns for. chapter18

2 GRASP Patterns and basic OO Design. Roel Wuyts OASS

Information Expert (or Expert)

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

COMP 6471 Software Design Methodologies

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

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

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

On to Object-oriented Design

ADVANCED SOFTWARE DESIGN LECTURE 4 GRASP. Dave Clarke

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

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

GRASP Design Patterns A.A. 2018/2019

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

Software Modeling & Analysis

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

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

Constantinos Constantinides Computer Science and Software Engineering Concordia University Montreal, Canada

17. GRASP: Designing Objects with Responsibilities

OO Design2. Design Artifacts

Patterns and Testing

Software Engineering

Mapping Designs to Code

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

Design of Software Systems (Ontwerp van SoftwareSystemen) 2 Basic OO Design. Roel Wuyts

Object-Oriented Design

CSSE 374: Logical Architecture. Shawn Bohner Office: Moench Room F212 Phone: (812)

CTIS 359 Principles of Software Engineering SOFTWARE DESIGN OO(A)D

Logical Architecture & Design Preliminaries

Domain Modeling- 2. Generalization

From designing to coding

Goal: build an object-oriented model of the realworld system (or imaginary world) Slicing the soup: OOA vs. OOD

PROCESSI DI PRODUZIONE E GESTIONE DEL SOFTWARE. Analysis and Design with UML. Paola Turci

Tecniche di Progettazione: Design Patterns

Object-Oriented Design

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

COMP 6471 Software Design Methodologies

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

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

Designing for Visibility & Mapping to Code CSSE 574: Session 4, Part 3

Creating Class Definitions from Design Class Diagrams: public class SalesLineItem // Java { private int quantity;

Object-Oriented Functional Analysis and Design for POS Example

Object Oriented Processes. R.K.Joshi Dept of Computer Science and Engg. IIT Bombay

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

Assigning Responsibilities

Object-Oriented Design II - GRASP

Object Oriented Software Development CIS Today: Object Oriented Analysis

On to Object-oriented Design

Software Development. Modular Design and Algorithm Analysis

Avancier Methods. Very basic design patterns. It is illegal to copy, share or show this document

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

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

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

Domain Modeling. CSSE 574: Week 1, Part 3. Steve Chenoweth Phone: Office (812) Cell (937)

What is a Model? Copyright hebley & Associates

CHAPTER 9 DESIGN ENGINEERING. Overview

Object-Oriented Design

CS6502- OBJECT ORIENTED ANALYSIS AND DESIGN UNIT I

Operations Contracts and Preliminaries on Design

MechEng SE3 Lecture 7 Domain Modelling

Final Exam CISC 475/675 Fall 2004

Chapter 3: Object Oriented Design

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

CS6502-OBJECT ORIENTED ANALYSIS AND DESIGN Two Marks Question with Answers Unit-I Introduction to OOAD

Software component interactions and sequence diagrams

CS/CE 2336 Computer Science II

OBJECT ORIENTED ANALYSIS AND DESIGN SYLLABUS

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

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

Study About the Relationship Between the Model-View-Controller Pattern and Usability

SE203b: OO Design for Software Engineers. Office: TEB349, Ext

Software Engineering - I

Design Patterns and Frameworks 1) Introduction

GRASP 2. CSC 440: Software Engineering Slide #1

Object Oriented Analysis and Design CS6502

Software Engineering

Object Oriented Processes. R.K.Joshi Dept of Computer Science and Engg. IIT Bombay

Object-Oriented Design and Modeling Using the UML

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

Domain Model and Domain Modeling

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

Object-Oriented Design II

18.1 Definitions and General OO Principles

Object-Oriented Design

Relationships amongst Objects

Review: Cohesion and Coupling, Mutable, Inheritance Screen Layouts. Object-Oriented Design CRC Cards - UML class diagrams

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

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)

Software Design and Analysis CSCI 2040

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

An Introduction to Patterns and Pattern Languages. Overview. Patterns -- Why? Patterns -- Why?

Appendix A - Glossary(of OO software term s)

Object Oriented. Analysis and Design

Software Modeling & Analysis

Review Software Engineering October, 7, Adrian Iftene

A Rapid Overview of UML

Software Engineering I (02161)

Object-Oriented Design I

Software Engineering I (02161)

Transcription:

Assigning Responsibilities by Larman Core design activity: The identification of objects and responsibilities and providing a solution in terms of an interaction diagram this is the creative part where the choices lead to good or bad designs cf. origins of O-O methodology; Smalltalk, Alan Kay

Assigning responsibility have an overview of responsibility for system operations (e.g. via contracts) need solution in terms of co-operating objects to achieve these design is identification of suitable objects assignment of responsibility

How to assign responsibility? Goal: to make a system that is easy to understand, maintain, reuse, extend exploration of design options/architectures CRC (Class-Responsibility-Collaborator) cards GRASP patterns...

CRC cards Due to Kent Beck, Ward Cunningham see original paper given as handout to encourage a different way of thinking about systems and design solutions identifying objects and assigning responsibility

Pattern name problem being solved solution Patterns codified solution principles, idioms no new ideas communication benefit: vocabulary; abstraction General info on software design patterns separately; here deal with Larman s take on design patterns

Patterns for responsibility by Larman General Responsibility Assignment Software Patterns (GRASP) (General Principles for Assigning Responsibility) GRASP 5 basic patterns Expert Creator High Cohesion Low Coupling Controler

Expert Most used pattern partial expert needs collaboration Benefits encapsulation; low coupling distributes behaviour across classes with required info `Do It Myself strategy --- Peter Coad

Part of Conceptual model date time Sale Sales LineItem quantity Contain s 1..* * Describedby Product Specification description price UPC Who should be responsible for knowing the grand total of the sale?

t := total() :Sale date time Sale New method total()

Collaboration Diagram to achieve this... t := total() :Sale 1*: [for each] sli := next() Sale 2: st := subtotal() date time total() sli:saleslineitem SalesLineItem :SalesLineItem SalesLineItem quantity New method subtotal()

t := total() :Sale 1*: [for each] sli := next() Sale 2: st := subtotal() date time total() 2.1: p := price() sli:saleslineitem SalesLineItem :SalesLineItem SalesLineItem quantity subtotal() :Product Specification Product Specification description price UPC New method price() Product Specification is the expert on price

Assigning responsibility by Expert Pattern Class Responsibility Sale SalesLineItem Knows sale total Knows line item subtotal ProductSpecification Knows product price

Creator Class B has responsibility to create instance of class A if B aggregates A objects B contains A objects B records instances of A objects B closely uses A objects B has the initialising data for A

Assigning Responsibility based on Creator Pattern makelineitem(quantity) :Sale Sale 1: create(quantity) New method :SalesLineItem date time makelineitem( total()

High Cohesion when the elements of a class (component) all work together to provide some wellbounded behaviour bad if a class is solely responsible for lots of different functions

Low Coupling Coupling A connected to B A has knowledge of B A relies on B Problems of high coupling changes ripple; difficult to understand alone, to reuse But excessive de-coupling: large, complex an evaluation pattern

Coupling typea has attribute or method that refers to an instance of typeb or typeb typea is a direct or indirect subclass of typeb typea is an interface; typeb implements the interface

Controller Assign responsibility for handling input system events to a class that represents the overall system represents the overall business or organisation (façade controller) represents an active entity in the real-world that does this (role controller) represents an artificial handler of all system events of a use case (use case controller)

Which class of object should be responsible for handling this system event message? It is a controller. enteritem(upc, quantity) :??? Controller Pattern choices: System --- POST Business or organisation --- Store Real-world controller --- Cashier Use Case handler --- BuyItemsHandler

enteritem(upc, quantity) :POST enteritem(upc, quantity) :Store enteritem(upc, quantity) :Cashier enteritem(upc, quantity) :BuyItemsHandler

Assigning System operations to one or more controller classes System endsale() enteritem() makepayment()... POST endsale() enteritem() makepayment() system operations discovered during system behavior analysis allocation of system operations during design using the Controller patte

Controller issues... UI objects and presentation layer should not have responsibility for fulfilling system events problem of bloated controllers single controller class handling all system events role-controllers (e.g. cashier object for handling makepayment) can be incohesive and avoid delegation

Object Store UPC Quantity Total Tendered Balance presses button Enter Item End Sale Make Payment Cashier onenteritem() Presentation Layer (Java applet) :POSTApplet system event message 1: enteritem(upc, qty) controller Domain Layer :POST 1.1: makelineitem(upc, qty) :Sale Desirable coupling.

Object Store UPC Quantity Total Tendered Balance presses button Enter Item End Sale Make Payment Cashier Presentation Layer (Java applet) :POSTApplet onenteritem() It is undesirable for a presentation layer objects such as a Java apple get involved in deciding how to ha domain processes. Business logic is embedded in the presentation layer, which is not us Domain Layer 1: makelineitem(upc, qty) :Sale POSTApplet should not send this message.