Study Guides (238,128)
158 (3)
158 .225 (2)

Exam Notes GRASP Design Patterns and Gang of Four Patterns.pdf

8 Pages
Unlock Document

Massey University
158 .225
Dave Parsons

The GRASP Design Patterns General Responsibility Assignment Software Patterns We want to be able to reuse as many things as possible. Heuristic – Allowing a person to discover or learn something for themselves Responsibility-Driven Design (RRD) Do object design by asking: What are the responsibilities of the object? Who does it collaborate with? Can use a CRC diagram with this: Class Responsibilities Collaboration Responsibilities Responsibilities are an abstraction Objects need to be assigned with responsibilities Are implemented with methods in objects Responsibility for persistence is a large-grained responsibility eg. User Interface. Fine-grained responsibility, eg. Involving data Patterns provide a vocabulary of design such as: state, straegy, façade The GRASP Patterns Very fundamental, basic principles of object design. Include: Information Expert Creator Controller Low Coupling High Cohesion Polymorphism Pure Fabrication Indirection Protected Variations Information Expert Most general, basic principle. Something that knows a lot about certain things. Assign a responsibility to the object that has the information necessary. Eg. Assign responsibility to employee Employee dateOfBirth getAge() Have many experts. Don’t want one complex information expert (Anti- Pattern, ‘God object’). A god object lacks cohesion and has too many responsibilities. Creator An object that creates something (eg. A) Choose an object that: Contains or aggregates A Records A Closely uses A Has the initialising data for A Eg. Board is the creator of square Dynamic Model: :Board create :Square Static Model: Board Square Controller What object in the domain receives requests for work from the UI layer. Choose a class whose name suggests the overall “system”, or represents the use case scenario. Low Coupling – evaluative pattern Things being linked together loosely. Coupling describes the degree of togetherness, and is reflected by the number of links. We want to minimise dependencies. To create reusable components that are resilient to change. High Cohesion Making sense as a unit. A measure of how strongly related and focused the responsibilities of a class are. Low cohesion do too many unrelated things (undesirable). Eg. Low Cohesion – Bad High Cohesion – Good :Monopoly Game :Monopoly Game :?? :?? playGame playGame doA doA doB doB doC Polymorphism Behaviour varies by type. Not really a pattern. Apply different behaviours to their appropriate type. Pure Fabrication Grouping of related responsibilities. Indirection Avoid direct coupling Use mediating objects Eg. Protected Variations Limit the effect of instability. Th
More Less

Related notes for 158 .225

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.