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

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

CSSE 374: Design Class Diagrams. Shawn Bohner Office: Moench Room F212 Phone: (812)

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

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

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

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

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

COMP 6471 Software Design Methodologies

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

GRASP: Patterns for. chapter18

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

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

We are at System Operation Contracts

GRASP Design Patterns A.A. 2018/2019

CSSE 490 Model-Based Software Engineering: Cougaar Model-Driven Architecture Example

17. GRASP: Designing Objects with Responsibilities

Information Expert (or Expert)

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

CSSE 490 Model-Based Software Engineering: Domain Specific Language Introduction

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

CSSE 490 Model-Based Software Engineering: Software Factories

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

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Logical Architecture & Design Preliminaries

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

Assigning Responsibilities by Larman

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

Model-Driven Architecture/ Development

Principles of Software Construction: Objects, Design, and Concurrency

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

Object-Oriented Design

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

CSSE 490 Model-Based Software Engineering: Domain Engineering

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

2 GRASP Patterns and basic OO Design. Roel Wuyts OASS

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

CSSE 490 Model-Based Software Engineering: MDSD and Case Study

Object-Oriented Design

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

Patterns and Testing

CSSE 490 Model-Based Software Engineering: More MBSD. Shawn Bohner Office: Moench Room F212 Phone: (812)

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

CSSE 490 Model-Based Software Engineering: Introduction to MetaModels

CSSE 490 Model-Based Software Engineering: Architecture Description Languages (ADL)

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

COMP 6471 Software Design Methodologies

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

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

Database Programming Project Proposals

CSSE 490 Model-Based Software Engineering: Transformational Programming

OODP OOAD Session 7a

Principles of Software Construction: Objects, Design, and Concurrency

Tecniche di Progettazione: Design Patterns

MSO Object Creation Singleton & Object Pool

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

How Rust views tradeoffs. Steve Klabnik

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

REDUCING THE RISK OF CARD NOT PRESENT FRAUD

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

References: Applying UML and patterns Craig Larman

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

MSO Lecture 6. Wouter Swierstra (adapted by HP) September 28, 2017

MSO Lecture 6. Wouter Swierstra. September 24, 2015

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

A few more things about Agile and SE. Could help in interviews, but don t try to bluff your way through

CSSE 490 Model-Based Software Engineering: Introduction to Domain Engineering

Principles of Software Construction: Objects, Design, and Concurrency

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

Operations Contracts and Preliminaries on Design

CPS122 Lecture: Cohesion and Coupling. 1. To introduce cohesion and coupling as criteria for evaluating designs

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

CAS 703 Software Design

Review Software Engineering October, 7, Adrian Iftene

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

Math 381 Discrete Mathematical Modeling

Implementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help

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

On to Object-oriented Design

Architectural Models. Section Outline. What is an architectural design? Architecture Types. Example Logical Architecture. Example Deployment Diagram

Practice Problems. Review, with SOME solutions

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

CS246 Software Abstraction and Specification Final Examination

VALLIAMMAI ENGINEERING COLLEGE

CS342: Software Design. November 21, 2017

Finding and Adding Payees in Payment Entry - Best Practices

Strategies That Work

You ve identified Ethernet, now what?

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

Assigning Responsibilities

18.1 Definitions and General OO Principles

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

Façade and the DP Wrap-Up

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

ONLINE PUBLISHING. FOR LOCAL GROUPs. Create posters, flyers and other promotional. materials from your desk.

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

Finding and Adding Payees in Payment Entry - Best Practices

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

CMSC 201 Spring 2017 Project 1 Number Classifier

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

Transcription:

CSSE 374: GRASP ing at the First Five Patterns Principles Shawn Bohner Office: Moench Room F22 Phone: (82) 877-8685 Email: bohner@rose-hulman.edu

Learning Outcomes: Patterns, Tradeoffs Identify criteria for the design of a software system and select patterns, create frameworks, and partition software to satisfy the inherent trade-offs. Examine GRASP Patterns: Creator Information Expert Controller Low Coupling High Cohesion Q3

Recall GRASP: 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 Contraindications Complex creation scenarios Recycling instances Conditional creation Q

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

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? Q3

GRASP: Controller Problem: What is the first object beyond the UI layer that 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 Q4

Controller Example What Domain Layer class should own handling of the enteritem system operation?

Layered view of Monopoly Game Who mediates between UI and Domain layers?

More on Monopoly Let MonopolyGame be the controller

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!) Q5

Controller Benefits and Issues Switch from façade to Increased potential for reuse use case controllers Can reason/control the state of a use case Benefits: e.g., don t close sale until payment is accepted Issues: Controller bloat too many system operations Controller fails to delegate tasks Controller has many attributes Delegate!

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

Coupling A measure of how strongly one element: is connected to, has knowledge of, or relies on other elements An Evaluative Principle Goal: Low (or weak) coupling What are some problems with high coupling? Q6

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

GRASP: Low Coupling Problem: How do you support low dependency, low change impact, and increased reuse? Solution: Assign a responsibility so that coupling remains low. Use this principle to evaluate alternatives.

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

Which option has Lower Coupling?

Advice: 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! Q8

Cohesion A measure of how strongly related and focused the responsibilities of a class (or method or package ) are Another Evaluative Principle Goal: high (strong) cohesion What are some problems with low cohesion? Q9

GRASP: High Cohesion Problem: How do you keep objects focused, understandable, and manageable, and as a side-effect, support low coupling? Solution: Assign a responsibility so that cohesion remains high. Use this principle to evaluate alternatives.

Which option has higher Cohesion?

Design Alternatives for High Cohesion

Cohesion Guidelines A highly cohesive class has small number of highly related operations/methods Does not do too much work Inherent trade-offs of Cohesion and Coupling To minimize coupling, a few objects have all responsibility To maximize cohesion, a lot of objects have limited responsibility Trade-off from alternative designs

Exercise on Creator Examples Break up into your project teams Given the following: Domain Model for BBVS. Identify a couple potential Controller Patterns 2. Identify a couple potential Information Expert Patterns

Store Address Phone# Customer name address phone# Video ID Transaction date Payment /amount: Money type authorization Initiates Recordsrental-of Pays-for Transacts Rents-from, Buys-from Stocks Selects * * * *..* 0..* Makes- Authorizes..* Rental duedate ReturnDate ReturnTime VideoDescription title subjectcategory VideoSupplier address name newvideos Basket Shelf location stock Membership ID startdate PricingPolicy perdayrentalcharge perdaylatecharge Obtains Maintains * Determines- rental-charge * Contains * * Stores- video-on Defines * Provides * * Describes Contains 0..* Provides 0..* Holds- videos-in

Homework and Milestone Reminders Read Chapter 8 on GRASP Examples Homework 3 BBVS Logical Architecture and Preliminary Design Due by :59pm Today, Tuesday, January 4 th, 20 Milestone 3 Junior Project SSDs, OCs, and Logical Architecture Due by :59pm on Friday, January 7th, 20 Homework 4 BBVS Design using GRASP Due by :59pm Tuesday, January th, 20