Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 25 GRASP The other four.

Similar presentations


Presentation on theme: "Chapter 25 GRASP The other four."— Presentation transcript:

1 Chapter 25 GRASP The other four

2 GRASP Polymorphism Indirection Pure Fabrication Protected Variations

3 Polymorphism Handle alternatives based on type
Simplify methods by removing cases

4 Fig. 25.1

5 Implementation in Monoploy

6 Fig. 25.2

7 Fig. 25.3

8 Fig Go Square

9 Fig Regular Square

10 Fig Income Tax

11 Fig Goto Jail

12 Improving coupling Piece knows square, player does not
Therefore player needs to use piece too often Refactor

13 Interfaces Choosing interfaces vs polymorhism

14 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

15 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

16 Dice in Monopoly Dice can be more general that just in monopoly
Some games have a dice cup

17 Fig. 25.8

18 Fig. 25.9

19 Design of objects Representaional decomposition
Behavioral decomposition

20 Indirection Avoid direct coupling

21 Fig

22 Persistent Storage Often a good use of indirection

23 Protected Variations Design for object, subsystems or systems to reduce instability Identify predicated points of variation Create a stable interface Similar to indirection Hide structure and information

24 Summary


Download ppt "Chapter 25 GRASP The other four."

Similar presentations


Ads by Google