Introduction to Design Patterns: Understanding GOF Patterns

Slide Note
Embed
Share

Explore the world of design patterns with a focus on Gang of Four (GOF) patterns. Understand the essence of design patterns, learn about GOF patterns, and discover how to select, apply, and use these patterns effectively. Dive into the fundamentals of design patterns, including creational and structural patterns, and grasp the significance of reusable solutions in software design.


Uploaded on Sep 21, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Gang of Four (GOF) Richard Helm Ralph Johnson John Vlissides Erich Gamma Design Patterns (DP) By P. S. Suryateja Asst. Professor CSE Dept Vishnu Institute of Technology

  2. Objectives Know what are design patterns? Know about GOF patterns. How to select and use a pattern? How to apply a pattern?

  3. Outline Introduction to design patterns What is a design pattern? Need of design patterns Use of design patterns Design patterns in Smalltalk MVC Describing design patterns Catalog of design patterns Organizing the catalog How to select a design pattern? How to use a design pattern?

  4. Outline (cont) Creational patterns Introduction Singleton Abstract Factory Factory Method Builder Prototype

  5. Outline (cont) Structural Patterns

  6. Introduction to Design Patterns

  7. What is a design pattern (DP)? Each 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. - Christopher Alexander Design patterns are repeatable / reusable solutions to commonly occurring problems in a certain context in software design.

  8. What is a design pattern (DP)? (cont ) Four essential elements of a pattern: Pattern name Problem Solution Consequences

  9. Need for design patterns Designing reusable object-oriented software (API s) is hard. Experienced designers Vs novice designers. Patterns make object-oriented software flexible, elegant and reusable. Solved a problem previously but don t remember when or how?

  10. Use of design patterns Make it easier to reuse successful designs and architectures. Make it easy for the new developers to design software. Allows to choose different design alternatives to make the software reusable. Helps in documenting and maintaining the software. To get a design right , faster.

  11. Why should we use DPs? These are already tested and proven solutions used by many experienced designers.

  12. MVC Architecture

  13. Design Patterns in Smalltalk MVC

  14. Describing design patterns 1. Pattern name and classification 2. Intent 3. Also known as 4. Motivation 5. Applicability 6. Structure 7. Participants 8. Collaborations

  15. Describing design patterns (cont ) 9. Consequences 10. Implementation 11. Sample code 12. Known uses 13. Related patterns

  16. Catalog of design patterns 1. Abstract Factory 2. Adapter 3. Bridge 4. Builder 5. Chain of Responsibility 6. Command 7. Composite 8. Decorator 9. Fa ade 10. Factory Method

  17. Catalog of design patterns (cont) 11. Flyweight 12. Interpreter 13. Iterator 14. Mediator 15. Memento 16. Observer 17. Prototype 18. Proxy 19. Singleton 20. State

  18. Catalog of design patterns (cont) 21. Strategy 22. Template Method 23. Visitor

  19. Abstract Factory

  20. Adapter

  21. Bridge

  22. Builder

  23. Chain of Responsibility

  24. Command

  25. Composite

  26. Decorator

  27. Faade

  28. Factory Method

  29. Flyweight

  30. Interpreter

  31. Iterator

  32. Mediator

  33. Memento

  34. Observer

  35. Prototype

  36. Proxy

  37. Singleton

  38. State

  39. Strategy

  40. Template Method

  41. Visitor

  42. Organizing the catalog

  43. How to select a design pattern Consider how design patterns solve design problems Scan intent sections Study how patterns interrelate Study patterns of like purpose Examine a cause of redesign Consider what should be variable in your design

  44. Relationships between patterns

  45. How to use a design pattern 1. Read the pattern once through for a overview. 2. Study the structure, participants and collaborations sections. 3. Look at the sample code section to see a concrete example of the pattern in action. 4. Choose names for pattern participants that are meaningful in the application context. 5. Define the classes. 6. Define application-specific names for the operations in the pattern. 7. Implement the operations to carry out the responsibilities and collaborations in the pattern.

  46. Creational Patterns

  47. Introduction Deals with how objects are created. Increase the system s flexibility in terms of what, who, how and when the object is created. Further classified into two types: 1. Class-creational patterns 2. Object-creational patterns Five creational patterns: 1. Abstract Factory 2. Builder 3. Factory Method 4. Prototype 5. Singleton

  48. Singleton Pattern To create exactly one object of a class and to provide a global point of access to it. Structure

  49. Singleton Pattern (cont) Non-Software Example

  50. Singleton Pattern (cont) Motivation: 1) Need to create exactly one user interface object. 2) Need to create only one print spooler.

Related