GRASP The other four What are the first five? What is the goal/purpose of using patterns?

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

Object-Oriented Analysis and Design CHAPTER 17, 25: GRASP PATTERNS 1.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
October R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) Ch 22: More GRASP Patterns.
Object-Oriented Software Engineering Practical Software Development using UML and Java Design Patterns – Part 2 Sources: Chapter 6: Using Design Patterns,
Chapter 25 GRASP: More Objects with Responsibilities 1CS6359 Fall 2011 John Cole.
Oct 21, R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the conceptual.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
Chapter 25 More Design Patterns. Polymorphism Issue: Conditional variation –If-then-else or switch statements –New variation or case: Conditional statements.
Fall 2009ACS-3913 R. McFadyen1 Polymorphism Indirection Pure Fabrication Protected Variations (Law of Demeter) More GRASP Patterns.
Architectural Design Principles. Outline  Architectural level of design The design of the system in terms of components and connectors and their arrangements.
March 6, R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the.
March R. McFadyen1 Pure Fabrication P Problem: You have a responsibility to assign to a class, but assigning it to a class in the conceptual.
Chapter 25 More Design Patterns.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Façade Design Pattern (1) –A structural design pattern.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Object Oriented Programming Key Features of OO Approach Data encapsulation –data and methods are contained in a single unit, object –promotes internal.
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
Chapter 17. GRASP General Responsibility Assignment Software Patterns (Principles) OOD: after identifying requirements, create domain model, define responsiblities.
1 Chapter 17 GRASP Design Patterns: Designing Objects with Responsibilities.
SOFTWARE DESIGN AND ARCHITECTURE
CSSE 374: Introduction to Gang of Four Design Patterns
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Chapter 17. Initial Object Design Inputs: requirements meetings various Use Cases – 10% complete Key risks addressed with preliminary programming System.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
Design Patterns. Patterns “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Copyright © Craig Larman All Rights Reserved Responsibility-Driven Design with the GRASP Patterns.
CSSE 374: More GRASP’ing for Object Responsibilities
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 05. Review Software design methods Design Paradigms Typical Design Trade-offs.
GRASP: Designing Objects with Responsibilities
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
IntellAgile Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
Abstraction ADTs, Information Hiding and Encapsulation.
OO Methodology Elaboration Iteration 2 - Design Patterns -
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
Com S 362: Object-Oriented Analysis and Design Refactoring.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 21 Design Patterns Reviewed from the New Perspective of Object-Oriented Design Ku-Yaw Chang Assistant Professor, Department.
Copyright © Craig Larman All Rights Reserved COMP-350 Object-Oriented Analysis and Design GRASP: Designing Objects with Responsibilities Reference:
Chapter 17 Designing with Responsibilities. Fig
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Component Design Elaborating the Design Model. Component Design Translation of the architectural design into a detailed (class-based or module- based)
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
GRASP: More Patterns for Assigning Responsibilities Presented By Dr. Shazzad Hosain.
(Further analysis and Refactoring) Larman, chapters 23 and 24 Glenn D. Blank, CSE432.
Object-Oriented Analysis and Design Week 12, 2009.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
GRASP.
Elaboration: Iteration 2. Elaboration: Iteration 2 Basics Iteration 1 ends with : All the software has been tested: The idea in the UP is to do early,
GRASP – Designing Objects with Responsibilities
BTS530: Major Project Planning and Design
GoF Patterns (GoF) popo.
Conception OBJET GRASP Patterns
Apply Expert, Creator, Controller, Low Coupling, High Cohesion
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
GoF Design Patterns (Ch. 26)
Chapter 25 GRASP The other four.
GoF Design Patterns (Ch. 26)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Chapter 25 GRASP The other four.
GRASP.
GoF Patterns Ch. 26.
Object Oriented System Design Responsibilities
Presentation transcript:

GRASP The other four What are the first five? What is the goal/purpose of using patterns?

Why use patterns? Decide how to divide responsibilities across objects. Data structures Methods Common, shorthand terms to discuss design. Get a feel for the underlying reasoning. GRASP and GoF are similar (if not identical).

GRASP Polymorphism Indirection Pure Fabrication Protected Variations

Polymorphism Handle alternatives based on type Simplify methods by removing if-then-else and case statements Easier extension to a new type, across multiple areas. All methods can be put in one object. aka Choosing Message or “Don’t ask ‘What Kind’”

Fig. 25.1

Implementation in Monopoly Different types of squares require different behavior/actions/methods. Switch on square.type CASE GoSquare: player receives $200 Case IncomeTaxSquare: play pays tax Etc. What is the action that triggers this?

Fig Each square type has it’s own “landed-on” method.

Fig i.e. loc = square_12; Square_12.landedOn(p);

Fig Go Square p.addCash(200);

Fig Regular Square

Fig Income Tax

Fig Goto Jail

Improving coupling Piece knows square, player does not Therefore player needs to use piece too often Refactor In a simulation “piece” does not have a real purpose.

Interfaces Choosing interfaces vs polymoprhism An interface allows coupling without a specific class hierarchy. With single-inheritance this can be too limiting. Tradeoff near-term efforts with the possibility of future extensions.

Pure Fabrication Assign a responsibility to avoid violations of High Cohesion and Low Coupling Make up an object to assign a highly cohesive set of responsibilities

Example: Databases and Sale Saving to database requires: DB Task requires a large number of support operations, unrelated to main class Sale Class has to be coupled to db connector Saving in DB is a general task using many support classes Fabricate DB persistence object Database is NOT part of the Object Model Persistent Storage insert(Object) Update(Object)

Dice in Monopoly Dice can be more general that just in monopoly Some games have a dice cup Created with a number of dice Created with dice having different number of sides (6, 12, 25, etc).

Fig. 25.8

Fig. 25.9

Design of objects Representaional decomposition What the thing is in the domain Behavioral decomposition Algorithm in a “made up” object Overuse turns into functional programming An Object is …. Pay attention to the data flows across objects.

Indirection Avoid direct coupling by adding another object. Supports re-use and future extensions. Indirection and polymorphism can create an adapter object “to protect the inner design.”

Fig If TaxMaster is swapped out, or new Tax program added, the new code is isolated in the adapter.

Persistent Storage Often a good use of indirection Collect all the database operations together in one place. Compare with GoF patterns coming up.

Protected Variations Design object, subsystems or systems to reduce instability Identify predicated points of variation and create a stable interface around them Indirection, polymorphism, interfaces, adapter, encapsulation, information hiding, etc. Hide structure and information in Data-driven design, Service lookups, uniform access, etc. Replaces the pattern “Don’t Talk to Strangers.” The farther the data, the more fragile the design.

Summary Why use patterns? What is the goal? What is an object? What are the 9 GRASP patterns? Where can you find the summary?