This repo consists of Sample code for Design Patterns and Solid principle in C#.
ModelBinder.cs file consists of sample
Method for converting DataTable <=> Model (Collection) Binder (Needs Testing with sample values).
Method for Cloning a C# Object (Deep Cloning). (Needs Testing with sample values)
- Solid Principle
- Open Close Principle
- Single Responsibility Principle
- Liskov Substitution Principle
- Interface Seggregation Principle
- Dependency Inversion Principle
Creational Pattern
- Singleton - Class has only one instance.
- FactoryMethod - An interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created.
- AbstractFactory - Provide an interface for creating families of related objects without specifying their concrete classes.
- Builder - Construct complex objects step-by-step.
- Prototype - Create new objects by copying an existing object.
Structural Pattern
- Adapter - Convert the interface of a class into another interface the client expects.
- Bridge - Decouple an abstraction from its implementation.
- Composite - Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions uniformly.
- Decorator - Allows behavior to be added to an individual object, dynamically, without modifying its class.
- Facade - Provides a simplified interface to a complex subsystem. It hides the complexities of the system and provides an easier way to interact with it.
- Flyweight - Minimizing memory usage by sharing as much data as possible with similar objects.
- Proxy - Provides a surrogate or placeholder for another object to control access to it. It allows you to add functionality (like lazy loading, access control, logging, etc.) without changing the original object's code.
Behavioral Pattern
- Iterator - Provides a way to access elements of a collection sequentially without exposing its underlying representation.
- Chain of Responsiblity - Allows passing a request along a chain of handlers. Each handler decides either to process the request or to pass it to the next handler in the chain.
- Observor - Establish a publish-subscribe relationship where subjects notify observers about state changes without being tightly coupled.
- TemplateMethod - defines the skeleton of an algorithm in a base class but lets subclasses override specific steps without changing the overall algorithm’s structure.
- Memento - Capture and externalize an object's internal state so that the object can be restored to that state later—without violating encapsulation