1 / 22

Chapter 17

Chapter 17. Designing with Responsibilities. Fig. 17.1. OOD. Requirements Domain model Then: Define classes Add methods to classes Define messaging Simple! RIGHT? - NOT. RDD. Responsibility - contract or obligation of a class Doing- Doing something itself

Download Presentation

Chapter 17

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 17 Designing with Responsibilities

  2. Fig. 17.1

  3. OOD • Requirements • Domain model • Then: • Define classes • Add methods to classes • Define messaging • Simple! RIGHT? - NOT

  4. RDD • Responsibility - contract or obligation of a class • Doing- • Doing something itself • Initiate an action in another object • Control or coordinate • Knowing- • Private data • Related objects • Things it can calculate

  5. Fig. 17.2

  6. GRASP • 9 patterns, first 5 in this chapter: • Creator • Information expert • Low coupling • Controller • High cohesion

  7. Creator • Problem: Who creates A? • Solution: Assign creation to B • IF: • B contains (compositely aggregates) A • B records A • B closely uses A • B has initializing data for A

  8. Fig. 17.4 apply Creator

  9. Fig. 17.5 Apply Creator

  10. Information Expert • Problem: Assign a responsibility to an object? • Solution: Choose the class that has the information to fulfill the responsibility

  11. Fig. 17.6

  12. Low Coupling • Problem: Reduce impact of change • Solution: Keep coupling low!

  13. Fig. 17.7

  14. Controller • Problem: What object beyond UI controls a system operation • Solution: Assign responibility to object • If • Overall “system”, “root object”, device that the software runs in, major subsystem • Represents a use case scenario within which the operation occurs

  15. Fig. 17.8 SSD

  16. Fig. 17.9

  17. Fig. 17.10

  18. Next Steps • Applied controller pattern • Now what goes beyond the :MonoployGame class?

  19. High cohesion • Problem: Keep objects focused, understandable, manageable (side effect support low coupling) • Solution: assign responsibilities to improve cohesion

  20. Fig. 17.11

  21. GRASP • General Responsibility Assignment Software Patterns • We just did 5 of 9 • There rest are in Chapter 25 • Polymorphism, Pure Fabrication, Indirection, Protected Variations

More Related