Popular posts from this blog
C# | Chain of Responsibility Design Pattern | Behavioral Design Pattern
The chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request. This pattern comes under behavioral patterns. In this pattern, normally each receiver contains reference to another receiver. If one object cannot handle the request, then it passes the same to the next receiver and so on. UML Diagram - Who is what? The classes, interfaces and objects in the above class diagram can be identified as follows: 1. Approver - Handler abstract class. 2. Clerk, Assistant Manager & Manager - ConcreteHandler classes. 3. Loan & LoanEventArgs - These classes are used for internal processing and holds request details.
C# | Factory Design Pattern | Creational Design Pattern
Defines an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. This structural code demonstrates the Factory method offering great flexibility in creating different objects. The Abstract class may provide a default object, but each subclass can instantiate an extended version of the object. Code Syntax - public interface ICar { void Start(); } public class SixSeater : ICar { public void Start() { throw new NotImplementedException(); } } public class FourSeater : ICar { public void Start() { throw new NotImplementedException(); } } public class CarFactory { public ICar GetCar(string carType) { switch(carType) { ...
Comments
Post a Comment