Designing with the GRASP Patterns - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Designing with the GRASP Patterns

Description:

Related to the methods and data of classes. Fulfilled with one or more methods. ... 2. Creator. 3. Controller. 4. Low Coupling. 5. High Cohesion. 6. Polymorphism. ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 26
Provided by: craigl66
Category:

less

Transcript and Presenter's Notes

Title: Designing with the GRASP Patterns


1
Designing with the GRASP Patterns
2
Overview
  • Assigning responsibilities to classes is a
    critical aspect of object-oriented design.
  • There are well-known best principles for
    assigning responsibilities.
  • Codified as the GRASP patterns.
  • We explore
  • Ideas.
  • Examples.
  • Practice

3
Objectives
  • Apply the GRASP patterns to assign
    responsibilities and design object interactions.
  • This is the most important objective of the
    course.
  • An inevitable activity, no matter what else is
    skipped.
  • Greatest influence on the quality of the software.

4
A Sample Partial Process
5
The Design of Behavior
  • What methods in what classes? How should objects
    interact?
  • These are critical questions in the design of
    behavior.
  • Poor answers lead to abysmal, fragile systems
    with low reuse and high maintenance.
  • Collaboration diagrams illustrate the design of
    behavior.
  • What is a good design?
  • What are the principles of a good design?

6
Assignment of Responsibilities
  • Design of behavior implies assigning
    responsibilities to software classes.
  • Responsibilities.
  • Knowing.
  • Doing.
  • Calculating, coordinating, creating,
  • A message in a collaboration diagram suggests a
    related responsibility.

7
Assignment of Responsibilities
  • A responsibility is
  • Related to the methods and data of classes.
  • Fulfilled with one or more methods.
  • Possibly spread across classes.

8
Responsibility Assignment is the Key
  • Appropriate assignment of responsibilities to
    classes is the key to successful design.
  • There are fundamental principles in assigning
    responsibilities that experienced designers
    apply.
  • These principles are summarized in the GRASP
    patterns.

9
The GRASP Patterns
  • GRASP
  • Acronym for General Responsibility Assignment
    Software Patterns.
  • Has nine core principles that object-oriented
    designers apply when assigning responsibilities
    to classes and designing message interactions.
  • Can be applied during the creation of
    collaboration diagrams.

10
The GRASP Patterns
  • Memorization and application of these patterns
    are critical for successful object-oriented
    designs.
  • 1. Expert.
  • 2. Creator.
  • 3. Controller.
  • 4. Low Coupling.
  • 5. High Cohesion.
  • 6. Polymorphism.
  • 7. Pure Fabrication.
  • 8. Indirection.
  • 9. Dont Talk to Strangers.

Memorizing and applying these nine principles
during every design exercise is the primary
course objective.
11
Expert
  • The most general purpose responsibility
    assignment principle?
  • Assign a responsibility to the information
    expert the class with the information necessary
    to fulfill the responsibility.

12
Expert
  • Related to another fundamental responsibility
    assignment strategy central to object-oriented
    design
  • Do It Myself. (Coad)
  • A Book calculates its own due date.
  • Closely related to and also known as
  • Put services with attributes. (Coad)
  • That which knows, does it. (Seive)

13
Creator
  • Who should create an instance of a particular
    class?
  • Consider assigning Class B the responsibility to
    create an instance of class A if one of the
    following is true
  • B contains A.
  • B aggregates A.
  • B records A.
  • B closely uses A.
  • B is the creator of A instances.
  • This pattern supports low coupling.

14
Creator
15
Controller
  • A controller is a class that handles a system
    event message.
  • What class should handle a system event message?

16
Controller (continued)
  • Assign the responsibility for handling a system
    operation message to one of these options
  • The business or overall organization (a façade
    controller).
  • The overall system (a façade controller).
  • An animate thing in the domain that would perform
    the work (a role controller).
  • An artificial class representing the use case (a
    use-case controller).

17
Controller - Facades
  • Facades are covers.
  • Intent - A class that (in some way) represents an
    overall cover.
  • Many possibilities.
  • Example The entire organization.

18
Controller - Facades
  • Other facades? A class representing the system.
    Examples
  • The software information system.
  • The device that includes a computer and
    software such as an ATM.
  • Others.

19
Controller
20
  • Before applying the GRASP patterns, lets
    step back and review the big-picture relationship
    between the artifacts we have developed...

21
Artifact Relationships
  • Every system operation initiates a
    collaboration diagram.

22
Optional Exercise
  • As far as possible, name and draw influence
    lines between artifacts.

23
Exercises
  • From memory, individually write down the
    definitions for
  • Expert.
  • Creator.
  • Controller.
  • Write the definitions on a large poster.
  • Create collaboration diagrams for the system
    operations indicated by the instructor.
  • Apply the GRASP patterns.
  • Annotate each message in your collaboration
    diagram with the chosen GRASP pattern.

24
What We Learned Reflection
  • Skillful assignment of responsibilities is
    critical to object-oriented design.
  • The GRASP patterns codify the fundamental
    principles.
  • Reflection.
  • Value?
  • When would you use this?
  • Use at work?

25
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com