Author of Bestselling 'Grokking' Courses on System Design & Coding interviews | Co-Founder of DesignGurus.io
๐ช๐ต๐ฒ๐ป ๐๐ผ ๐๐ฒ๐น๐ฒ๐ฐ๐ ๐๐ฒ๐๐ถ๐ด๐ป ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐ฌ? Choosing the correct design pattern in software engineering is critical to practical problem-solving. This post will try to simplify the process, helping you decide between patterns based on specific needs. To select a pattern, we must first go through the problem identification. If the problem is related to: ๐ธ Object Creation? โ Creational Patterns ๐ธ Object Assembly? โ Structural Patterns ๐ธ Object Interactions? โ Behavioral Patterns 1. Singleton: Ensures only one instance exists. 2. Factory Method: Delegates object instantiation to subclasses. 3. Abstract Factory: Creates related object families without specifying their concrete classes. 4. Prototype: Clones objects for a prototypical instance. 5. Builder: Constructs complex objects step by step. 6. Adapter: Bridges incompatible interfaces. 7. Bridge: Separates abstraction from implementation. 8. Composite: Treats single and composite objects uniformly. 9. Decorator: Adds behaviors to objects dynamically. 10. Facade: Simplifies complex system interfaces. 11. Flyweight: Shares objects to reduce memory. 12. Proxy: Controls object access. 13. Observer: Notifies changes to multiple objects. 14. Strategy: Encapsulates interchangeable algorithms. 15. Command: Encapsulates a request as an object. 16. State: Changes object behavior with internal state. 17. Visitor: Adds operations to object structures without modifying them. 18. Memento: Captures and restores object states externally. 19. Iterator: Sequentially accesses elements of a collection. 20. Mediator: Centralizes complex communications. 21. Chain of Responsibility: Passes requests along a chain of handlers. 22. Template Method: Defines the skeleton of an algorithm. โก Reference: ๐๐ซ๐จ๐ค๐ค๐ข๐ง๐ ๐๐๐ฌ๐ข๐ ๐ง ๐๐๐ญ๐ญ๐๐ซ๐ง๐ฌ ๐๐จ๐ซ ๐๐ง๐ ๐ข๐ง๐๐๐ซ๐ฌ ๐๐ง๐ ๐๐๐ง๐๐ ๐๐ซ๐ฌ - https://lnkd.in/gHYiMuEh โก Join my newsletter to learn tips on system design and problem-solving: https://lnkd.in/gpHAFd9t #designpatterns #systemdesign #softwarearchitecture Design Gurus
How about another types of design patterns ? Like EAI Or SOA design Patterns ? Why only GoF ?
I prefer pub/sub over observer because you can create topics and not flood all objects with event dispatches. This means you can use it as a central event data bus in your application. The rest are spot on. Kudos.
Thanks for sharing this!
Thanks for sharing
Its quite useful, thank you!
Legend
Useful tips
Arslan Ahmad Thanks for your effort
Woww..! This reminds us of one of our projects! The client was in the financial services industry. They needed a centralized notification system. The purpose was to send alerts and updates to different services and applications. So, the Singleton pattern became our obvious choice. It was used to create a single instance of the notification manager. But, as their operations expanded, the singleton pattern began to show limitations: - Responsiveness - Maintenance complexity We thought of a solution and decided to transition, from a singleton pattern to an observer pattern. In this, the notification manager (Subject) maintained a list of dependent services (observers) that needed to be notified of changes or new alerts. Following this approach was helpful since we saw results like: - Improved scalability - Simplified maintenance. - Enhanced Responsiveness Thanks for bringing this up, Arslan Ahmad