Presentation is loading. Please wait.

Presentation is loading. Please wait.

IntellAgile www.craiglarman.com Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns.

Similar presentations


Presentation on theme: "IntellAgile www.craiglarman.com Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns."— Presentation transcript:

1 IntellAgile www.craiglarman.com Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns

2 IntellAgile 2 Overview  A critical skill is designing or thinking in objects. This can be practiced based on explainable principles. We will start applying these.  You will be able to:  Apply Expert, Creator, Controller, Low Coupling, High Cohesion  Design for low representational gap  Design for visibility  Define use case realizations  Relate the UP artifacts interaction diagrams designing objects design class diagrams mapping code

3 IntellAgile 3 MOTIVATION: Introduction  Now what happens?  What object should receive this message?  What objects should interact to fulfill the request, and how? interaction diagrams designing objects design class diagrams mapping code

4 IntellAgile 4 DEFINITION: Responsibility-Driven Design (RDD)  Detailed object design is usually done from the point of view of the metaphor of:  Objects have responsibilities  Objects collaborate  In RDD we do object design such that we will ask questions such as:  What are the responsibilities of this object?  Who does it collaborate with? interaction diagrams designing objects design class diagrams mapping code

5 IntellAgile 5 DEFINITION: Responsibilities  Responsibilities are an abstraction.  The responsibility for persistence. –Large-grained responsibility.  The responsibility for the sales tax calculation. –More fine-grained responsibility.  They are implemented with methods in objects.  1 method in 1 object  5 methods in 1 object  50 methods across 10 objects interaction diagrams designing objects design class diagrams mapping code

6 IntellAgile 6 DEFINITION: Patterns  Patterns are named problem-solution pairs to common problems, typically showing a popular, robust solution.  “Façade” “Information Expert” …  They provide a vocabulary of design. interaction diagrams designing objects design class diagrams mapping code

7 IntellAgile 7 DEFINITION: GRASP Patterns  What guiding principles to help us assign responsibilities?  These principles are captured in the GRASP patterns.  General Responsibility Assignment Software Patterns.  Very fundamental, basic principles of object design. interaction diagrams designing objects design class diagrams mapping code

8 IntellAgile 8 The 9 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion 6.Polymorphism 7.Pure Fabrication 8.Indirection 9.Protected Variations Memorizing and applying these is the most important, useful objective of this seminar. interaction diagrams designing objects design class diagrams mapping code

9 IntellAgile 9 PATTERN: Information Expert  What is most basic, general principle of responsibility assignment?  Assign a responsibility to the object that has the information necessary to fulfill it.  “That which has the information, does the work.”  E.g., What software object calculates sales tax? 1. What information is needed to do this? 2. What object or objects has the majority of this information. interaction diagrams designing objects design class diagrams mapping code

10 IntellAgile 10 Demonstration  The coach will illustrate applying Information Expert… interaction diagrams designing objects design class diagrams mapping code

11 IntellAgile 11 Designing for Low Representational Gap interaction diagrams designing objects design class diagrams mapping code

12 IntellAgile 12 Designing for Low Representational Gap  Contraindication:  We do not design for low representational gap regarding actors.  E.g., we don’t make a software class Clerk do all the work in the software system.  Why?? interaction diagrams designing objects design class diagrams mapping code

13 IntellAgile 13 Designing for Visibility  Fact: To send a message to B, A must have visibility to B. It doesn’t happen by “magic.”  Kinds of visibility:  Attribute  Parameter  Local  Global interaction diagrams designing objects design class diagrams mapping code

14 IntellAgile 14 DEFINITION: Attribute Visibility interaction diagrams designing objects design class diagrams mapping code

15 IntellAgile 15 DEFINITION: Parameter Visibility interaction diagrams designing objects design class diagrams mapping code

16 IntellAgile 16 DEFINITION: Local Visibility interaction diagrams designing objects design class diagrams mapping code

17 IntellAgile 17 PATTERN: Creator  What object creates an X?  Ignores special-case patterns such as Factory.  Choose an object C, such that:  C contains or aggregates X  C closely uses X  C has the initializing data for X  The more, the better. interaction diagrams designing objects design class diagrams mapping code

18 IntellAgile 18 Demonstration  The coach will illustrate applying Creator… interaction diagrams designing objects design class diagrams mapping code

19 IntellAgile 19 PATTERN: Controller  What object in the domain (or application coordination layer) receives requests for work from the UI layer? interaction diagrams designing objects design class diagrams mapping code

20 IntellAgile 20 PATTERN: Controller  Solution: Choose a class whose name suggests:  The overall “system,” device, or subsystem –A kind of Façade class  Or, represents the use case scenario or session interaction diagrams designing objects design class diagrams mapping code

21 IntellAgile 21 Demonstration  The coach will illustrate applying Controller… interaction diagrams designing objects design class diagrams mapping code

22 IntellAgile 22 PATTERN: Low Coupling  Assign responsibilities so that coupling remains low.  What does low coupling mean? interaction diagrams designing objects design class diagrams mapping code

23 IntellAgile 23 PATTERN: High Cohesion  Assign responsibilities so that cohesion remains high?  What does high cohesion mean? interaction diagrams designing objects design class diagrams mapping code

24 IntellAgile 24 DEFINITION: Use Case Realizations  In the vocabulary of the UP and use case modeling, when we design the objects to handle the systems operation for a scenario, we are designing a use case realization. interaction diagrams designing objects design class diagrams mapping code

25 IntellAgile 25  Individually, review and rewrite the 5 GRASP patterns we’ve discussed.  In small teams at the whiteboard, without notes, write definitions of the 5 GRASP patterns. interaction diagrams designing objects design class diagrams mapping code

26 IntellAgile 26  In small teams at the whiteboard, create an interaction diagram for enterItem.  Use the text’s operation contract as a basis. p. 185  Use the text’s Domain Model as a basis, when designing for “low representational gap.” p. 176  Apply Controller, Information Expert, Creator, Low Coupling, High Cohesion.  Consider low representational gap  Design for visibility interaction diagrams designing objects design class diagrams mapping code

27 IntellAgile 27 UP Artifacts interaction diagrams designing objects design class diagrams mapping code

28 IntellAgile 28 Recommended Resources interaction diagrams designing objects design class diagrams mapping code

29 IntellAgile 29  GRASP Review. Tell a partner the 3 GRASP patterns (Information Expert, Controller, Creator), and define them. Try to give examples from the designs you’ve created. interaction diagrams designing objects design class diagrams mapping code

30 IntellAgile 30  Solution Review.  The coach will review the solutions, considering –GRASP patterns –Low representational gap –Designing for visibility interaction diagrams designing objects design class diagrams mapping code

31 IntellAgile 31  Without notes, draw all UP disciplines and artifacts discussed, and relate them. interaction diagrams designing objects design class diagrams mapping code

32 IntellAgile 32  Objectives assessment. Can you:  Apply Expert, Creator, Controller, Low Coupling, High Cohesion  Design for low representational gap  Design for visibility  Define use case realizations  Relate the UP artifacts interaction diagrams designing objects design class diagrams mapping code


Download ppt "IntellAgile www.craiglarman.com Copyright © 2002 Craig Larman. All rights reserved. Object Design and Use- Case Realizations with GRASP Patterns."

Similar presentations


Ads by Google