Download presentation
Presentation is loading. Please wait.
Published byRichard Wilkinson Modified over 9 years ago
1
Chapter 7 GRASP patterns Dr Seham Mostefai CAP 252
2
Outline Historical background What is a pattern? GRASP Patterns Dr Seham Mostefai CAP 2522
3
Historical background (1) Architecture Christopher Alexander, professor of architecture: “A pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.” C.Larman Slides on GRASP: Designing objects with responsibilities Dr Seham Mostefai CAP 252 Patterns were used far before software design like in: 3
4
Historical background (2) Dress making Dr Seham Mostefai CAP 252 C.Larman Slides on GRASP: Designing objects with responsibilities You can make a dress by specifying the route of a scissors through a piece of cloth Or, by following a pattern. 4
5
Historical background (3) …and other fields – Mature engineering disciplines have handbooks describing successful solutions to known problems – Automobile designers don't design cars from scratch, they reuse standard designs learnt from experience – Should software engineers make use of patterns? Why? Dr Seham Mostefai CAP 2525
6
Patterns in Software design Developing software from scratch is expensive Patterns support reuse of software design solutions – 1987: Beck & Cunningham: patterns for UI – 1990-200: Gamma, Helm, Johnson and Vlissides: Gof patterns – More recently: C. Larman: GRASP patterns. – UML is a language, how can we apply it? Dr Seham Mostefai CAP 2526
7
What is a software pattern? Alexander: “A pattern is a recurring solution to a standard problem, in a context.” In Object technology C. Larman: “ a pattern is a named problem/solution pair that can be applied in new contexts, with advice on how to apply it in novel situations” Dr Seham Mostefai CAP 2527
8
Pattern main features Must have a significant and suggestive name Designed to solve a particular problem Facilitates communication and understanding and furnishes a solution Dr Seham Mostefai CAP 2528
9
GRASP Patterns GRASP= General Responsibility Assignment Software Pattern Name chosen to suggest the importance of grasping fundamental principles to successfully design object-oriented software Describe fundamental principles of object design and responsibility expressed as patterns Dr Seham Mostefai CAP 2529
10
Five GRASP Patterns Information Expert Creator Controller Low Coupling High Cohesion Dr Seham Mostefai CAP 25210
11
Information Expert Pattern(1) Name: Information Expert Problem: How to assign responsibilities to objects? Solution: Assign responsibility to the class that has the information needed to fulfill it? Example: ordering a meal in a restaurant Which classes have the responsibility to get the total of an order? Dr Seham Mostefai CAP 25211 OrderDishLineDishDescription
12
Information Expert Pattern (2) Effect on collaboration diagram Dr Seham Mostefai CAP 25212 :Invoice:Order:DishLine T:=total() 1*:LT:=LineTotal() :DishDescription 2: P:=Price() By Expert
13
Information Expert Pattern (3) Effect on class diagram Dr Seham Mostefai CAP 25213
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.