Presentation is loading. Please wait.

Presentation is loading. Please wait.

Oct 2, 200191.3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary (www.m-w.com): Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:

Similar presentations


Presentation on theme: "Oct 2, 200191.3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary (www.m-w.com): Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:"— Presentation transcript:

1 Oct 2, 200191.3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary (www.m-w.com): Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function: noun Date: 1753 : an interpretation of what is not human or personal in terms of human or personal characteristics : HUMANIZATIONHUMANIZATION Anthropomorphism

2 Oct 2, 200191.3913 Ron McFadyen2 Anthropomorphism Anthropomorphism: Object-oriented programming works like human organizations. Each object will communicate with another one by sending messages. So the software objects work by just sending those messages.

3 Oct 2, 200191.3913 Ron McFadyen3 Responsibility-Driven Design (RDD) n Detailed object design is usually done from the point of view of the metaphor of: – Objects have responsibilities – Objects collaborate – Similar to how we conceive of people n 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?

4 Oct 2, 200191.3913 Ron McFadyen4 Figure 3.1 on page 31 - Architectural Layers

5 Oct 2, 200191.3913 Ron McFadyen5 Introduction n What object should receive this message? n What objects should interact to fulfill the request, and how?

6 Oct 2, 200191.3913 Ron McFadyen6 Responsibilities n Responsibilities are an abstraction. – The responsibility for persistence. Large-grained responsibility. – The responsibility for the sales tax calculation. More fine-grained responsibility. n They are implemented with methods in objects. – 1 method in 1 object – 5 methods in 1 object – 50 methods across 10 objects

7 Oct 2, 200191.3913 Ron McFadyen7 Fundamental Principles of Object Design—GRASP Patterns n guiding principles to help us assign responsibilities n These principles are captured in the GRASP patterns. – General Responsibility Assignment Software Patterns. – Very very fundamental, simple, basic principles of object design.

8 Oct 2, 200191.3913 Ron McFadyen8 GRASP Patterns 1.Expert 2.Creator 3.Controller 4.Low Coupling 5.High Cohesion

9 Oct 2, 200191.3913 Ron McFadyen9 Expert n What is most basic, general principle of responsibility assignment? n Assign a responsibility to the object that has the information necessary to fulfill it. – “That which has the information, does the work.” – Not a sophisticated idea - rather, it is common sense – E.g., What software object calculates sales tax? What information is needed to do this? What object or objects has the majority of this information.

10 Oct 2, 200191.3913 Ron McFadyen10 In the NextGEN POS application, it is necessary to know the grand total of a sale. Where should that responsibility be placed? Expert suggest that we should look for a class that has the information needed to determine the grand total. If our design is just beginning, we look at the Domain Model and bring the pertinent conceptual classes into the class model Pages 221-226

11 Oct 2, 200191.3913 Ron McFadyen11 What information is needed to determine the grand total? It is necessary to know about all the SalesLineItem instances of a sale and the sum of their subtotals. A Sale instance contains these … Sale is the Expert choice for having the responsibility of knowing the grand total.

12 Oct 2, 200191.3913 Ron McFadyen12 Expert leads us to place the method getTotal() in Sale

13 Oct 2, 200191.3913 Ron McFadyen13 A line item knows its quantity and the associated Product, so it is the expert … SalesLineItem should determine the line item subtotal

14 Oct 2, 200191.3913 Ron McFadyen14 Only the Product Specification knows the price; so Product Specification needs a method...

15 Oct 2, 200191.3913 Ron McFadyen15 Creator n What object creates an X? – Ignores special-case patterns such as Factory. n Choose an object C, such that: – C contains or aggregates X – C closely uses X – C records instances of X objects – C closely uses X objects – C has the initializing data for X

16 Oct 2, 200191.3913 Ron McFadyen16 Controller n What object in the domain (or application coordination layer) receives requests for work from the UI layer?

17 Oct 2, 200191.3913 Ron McFadyen17 Controller n Candidates: – An object whose name reflects the use case. e.g., RentingVideosUCHandler part of the Application Coordination layer. – An object whose name reflects the overall server, business, or large-scale entity. A kind of “façade” object. e.g., Store, RentingServer

18 Oct 2, 200191.3913 Ron McFadyen18 Figure 16.7 - desirable coupling of interface layer to domain layer

19 Oct 2, 200191.3913 Ron McFadyen19 Low Coupling n How do we assign responsibilities so that coupling remains low? n Coupling: a measure of how strongly one element is connected to, has knowledge of, or relies on other elements. n Low coupling: not dependent on too many other elements n High coupling results in – classes that are harder to understand in isolation – changes to related classes force local changes – classes that are harder to reuse

20 Oct 2, 200191.3913 Ron McFadyen20 High Cohesion n How do we assign responsibilities so that cohesion remains high? n Cohesion: a measure of how strongly related and focused the responsibilities of an element are. n A class with highly related responsibilities and which does not do excessive amounts of work has high cohesion n Low cohesion results in classes that – are hard to comprehend – hard to reuse – hard to maintain – delicate - constantly affected by change


Download ppt "Oct 2, 200191.3913 Ron McFadyen1 From the Merriam-Webster’s online dictionary (www.m-w.com): Main Entry: an·thro·po·mor·phism Pronunciation: -"fi-z&m Function:"

Similar presentations


Ads by Google