- 2071 Magh · 7 marks
Pattern based design and benefits
Short answer
Pattern-based design applies named proven solutions (GoF, GRASP) to recurring problems instead of designing from scratch. Benefits include reuse of experience, common vocabulary, better quality (loose coupling, high cohesion), faster design, easier maintenance, and learning support. Example: Strategy for payment methods with Factory for creation and Singleton for gateway.
What is pattern based design? What are the added benefits of using patterns? Prepare an illustrative note on pattern based design.
Pattern based design
A pattern is a named and well-known description of a problem and its proven solution, with advice on how to apply it in new contexts. Pattern-based design means designing software by recognising recurring design problems and applying suitable patterns (GRASP for assigning responsibilities, GoF patterns like Factory, Singleton, Observer, Strategy) rather than designing everything from scratch.
Typical description of a pattern: name, problem (context and forces), solution, consequences. Example: Problem: who should create OrderLine objects? Solution (Creator pattern): assign the creation to the class that contains or closely uses them, here Order.
Categories: creational (Singleton, Factory), structural (Adapter, Facade, Composite), behavioural (Observer, Strategy, Command); and GRASP responsibility patterns.
Problem in a context
| recognise
v
Choose a pattern ---> Apply to own classes
| |
+-> check consequences -+--> Pattern-based design
Added benefits of using patterns
- Reuse of experience: solutions already tested by many designers.
- Common vocabulary: "use an Observer here" communicates a whole structure.
- Better design quality: loose coupling, high cohesion, flexibility, extensibility.
- Faster design: fewer design decisions from scratch, fewer mistakes.
- Easier maintenance and documentation: other developers who know the patterns understand the design quickly.
- Supports learning: helps beginners design like experts.
- Supports refactoring to well-defined structures.
Illustrative note
For a payment module that must support card, e-wallet and bank transfer, a Strategy pattern is used: an interface PaymentMethod with pay(amount) and concrete classes CardPayment, WalletPayment. A new method is added by writing a new class, with no change in the checkout code. A Factory creates the correct object, and Singleton can provide the payment gateway connection.
Caution: patterns must not be used blindly; applying them where they are not needed adds complexity.
Related questions
- Pattern vs framework; GRASP patterns · Object Oriented Analysis and Design, chapter 3
- Short note: Design patterns in deployment · Object Oriented Analysis and Design, chapter 3
- Framework and design pattern with example · Object Oriented Analysis and Design, chapter 3
- Design patterns and their benefits · Software Engineering, chapter 5
- Benefits of computer based control · Embedded System, chapter 7
- Typical damage patterns in masonry buildings · Design of Timber and Masonry Structures, chapter 6
- Flow patterns in plant layout · Industrial Engineering and Management, chapter 2
All Object Oriented Analysis and Design chapter 3 questions →