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

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

GRASP Design Patterns A.A. 2018/2019

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

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

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

GRASP: Patterns for. chapter18

Information Expert (or Expert)

17. GRASP: Designing Objects with Responsibilities

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

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

Assigning Responsibilities by Larman

On to Iteration 3, and Activity Diagrams CSSE 574: Session 6, Part 1

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

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

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

ADVANCED SOFTWARE DESIGN LECTURE 4 GRASP. Dave Clarke

Domain Modeling: Associations and Attributes

More Object Design with GoF Patterns (continued) CSSE 574: Session 7, Part 3

Logical Architecture & Design Preliminaries

More Object Design with GoF Patterns CSSE 574: Session 7, Part 2

Object-Oriented Design

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

COMP 6471 Software Design Methodologies

Operations Contracts and Preliminaries on Design

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

2 GRASP Patterns and basic OO Design. Roel Wuyts OASS

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

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

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

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

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

Object-Oriented Design

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

On to Object-oriented Design

Tecniche di Progettazione: Design Patterns

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

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

Principles of Software Construction: Objects, Design, and Concurrency

Patterns and Testing

GRASP 2. CSC 440: Software Engineering Slide #1

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

Persistence Frameworks with GoF Patterns (State & Command) CSSE 574: Session 7, Part 4

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

Software Engineering

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

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

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

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

Assigning Responsibilities

Requirements and Design Overview

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

OODP OOAD Session 7a

OBJECT ORIENTED ANALYSIS AND DESIGN SYLLABUS

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

CS342: Software Design. November 21, 2017

18.1 Definitions and General OO Principles

VALLIAMMAI ENGINEERING COLLEGE

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

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

CS6502- OBJECT ORIENTED ANALYSIS AND DESIGN UNIT I

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

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

COMP 6471 Software Design Methodologies

Design Patterns. CSC207 Fall 2017

PART 4 Elaboration Iteration 2 More Patterns

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Software Design and Analysis CSCI 2040

CSSE 374: UML Activity Diagrams. Shawn Bohner Office: Moench Room F212 Phone: (812)

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

UNIT 1-UMAL DIAGRAMS. Q.No. Question Competence Level. 1 What is Object Oriented analysis & Design? Remembering BTL1

References: Applying UML and patterns Craig Larman

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

MSO Object Creation Singleton & Object Pool

Design Pattern Detection

OO Design2. Design Artifacts

The great primary-key debate

PART 5 Elaboration Iteration 3 Intermediate topics. Iteration 3

Software Modeling & Analysis

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

UNIT V CODING AND TESTING 9 Mapping design to code Testing: Issues in OO Testing Class Testing OO Integration Testing GUI Testing OO System Testing.

Introduction - SENG 330. Object-Oriented Analysis and Design

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

MSO Lecture 12. Wouter Swierstra (adapted by HP) October 26, 2017

Object Oriented. Analysis and Design

ER to Relational Mapping

Design Patterns. CSC207 Winter 2017

Design. Eric McCreath

spot buy center for imec, meet oazo!

Review Software Engineering October, 7, Adrian Iftene

MSO Lecture 6. Wouter Swierstra. September 24, 2015

Object Design with GoF Patterns, continued. Curt Clifton Rose-Hulman Institute of Technology

EINDHOVEN UNIVERSITY OF TECHNOLOGY

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

HCA Tech Note 600. User Implemented Device Classes for Class Creators

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

On to Object-oriented Design

CS 370 Design Heuristics D R. M I C H A E L J. R E A L E F A L L

Mapping Designs to Code

Transcription:

GRASP ing at the First 5 Patterns Principles CSSE 574: Session 3, Part 4 Steve Chenoweth Phone: Office (812) 877-8974 Cell (937) 657-3885 Email: chenowet@rose-hulman.edu

GRASP General Responsibility Assignment Software Patterns (or Principles) Focus for Chapter 17 and today 1. Low Coupling 2. High Cohesion 3. Information Expert 4. Creator 5. Controller 2

Coupling A measure of how strongly one element: is connected to, has knowledge of, or relies on other elements Want low (or weak) coupling What are some problems with high coupling?

Example Suppose we need to create a Payment instance and associate it with a Sale Who should be responsible?

Option 1

Option 2

Lower Coupling?

Common Couplings A has an attribute of type B A calls a static method of B A has a method with a parameter or variable of type B A implements an interface B A is a subclass of B Very strong coupling

Pick Your Battles Coupling to stable, pervasive elements isn t a problem e.g., java.util.arraylist Coupling to unstable elements can be a problem Unstable interface, implementation, or presence Clearly can t eliminate coupling completely!

Cohesion A measure of how strongly related and focused the responsibilities of a class (or method or package ) are Want high cohesion What are some problems with low cohesion?

High Cohesion?

Guideline A highly cohesive class Has a small number of highly related methods Does not do too much work

Information Expert Problem: What is a general principle of assigning responsibilities? Solution: Assign a responsibility to the class that has the necessary information the most general principle?

Where do we look for classes? In the Design model if the relevant classes are there Otherwise: Look to Domain model for motivation, then add classes to the Design model

Information Expert Examples Who should be responsible for knowing the grand total of a Sale? Given that a Piece (in Monopoly) just landed on a Square, who should be responsible for calculating the rent due?

Information Expert Contraindications Sometimes Information Expert will suggest a solution that leads to coupling or cohesion problems Consider: Who should be responsible for saving a Sale in a database?

Imposter If you think this is too hard on literary criticism, read the Wikipedia article on deconstruction.

Creator Problem: Who should be responsible for creating a new instance of some class? Solution: Make B responsible for creating A if B contains or is a composition of A B records A B closely uses A B has the data to initialize A Most important The more matches the better.

Creator Examples In Monopoly simulator, who should create Squares? Pieces? Dice? In NextGen POS, who should create SalesLineItems? ProductDescriptions?

Creator Contraindications Complex creation scenarios Recycling instances Conditional creation

Controller Problem: What first object beyond the UI layer receives and coordinates a system operation Solution: Assign the responsibility to either A façade controller, representing the overall system and handling all system operations, or A use case controller, that handles all system events for a single use case

Example What domain layer class should own handling of the enteritem system operation?

Guidelines Controller should delegate to other domain layer objects Use façade controller when There are a limited number of system operations, or When operations are coming in over a single pipe Use use case controller when a façade would be bloated (low cohesion!)

Controller Benefits Increased potential for reuse Can reason/control the state of a use case e.g., don t close sale until payment is accepted

Controller Issues Switch from façade to use case controllers Controller bloat too many system operations Controller fails to delegate tasks Controller has many attributes Delegate!