Design pattern is time tested solution for reoccurring software design problems. It is reusable solution to common problem in software design.
It helps in Organizing code, improve scalability and enhance maintainability.
Three major category -
1. Creational (object creation)
- Factory - eg( Notification (Email/PushNotification/SMS)
- Abstract Factory
2. Structural
- Singleton
- Prototype
- Adaptor - Non compatible Interface/system , made to communicate
- Proxy
3. Behavioral
Defines a family of algorithms, encapsulates each one, and makes them interchangeable.
Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.
Non Gang Of Four (GOF) pattern:
- CQRS
- Repository -(Abstraction over data access layer(DAL)...makes Unit testing easy...)
Adapter with example
Adapting an Old Payment System
Scenario: Developing a modern e-commerce platform that interacts with various payment gateways. However, one of the payment gateways uses an outdated interface that is incompatible with your platform’s current payment interface. Instead of rewriting the legacy code, we can use the Adapter Pattern to integrate it seamlessly.
Comments
Post a Comment