Tag: Design Patterns

State Design Pattern

Introduction: Sometimes you want to build a class where its behavior changed according to its state. State Design pattern provides a good class structure to solve this issue. State Design pattern also known as Object for state pattern is used to represent the state of an object and the object behavior will changed according to Read More …

Command Design Pattern

Introduction: Command Design Pattern enables you to encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. Example: The below code demonstrates the Command pattern to be used on a simple calculator. This caluclator doing unlimited number of undo’s & Redo’s . One Read More …

Iterator Design Pattern

Introduction: Sometimes you want to access a collection of objects in a sequential way without even expose how things is going inside your implementation . Iterator Design Pattern Provides you with a Skelton of how to design your classes to solve this issue. Example: static void Main(string[] args) { ListAggregate a = new ListAggregate(); a[0] Read More …

Mediator Design Pattern

Introduction: Sometimes you want to design your classes set that interact with each other in a loosely coupled manner by keeping your classes away from referring each other directly… Mediator Design Pattern solve this issue by promoting the idea of loosely coupling classes Example:   static void Main(string[] args) { CountryList countrylist = new CountryList(); Read More …

Interpreter Design Pattern

Introduction: Sometimes you want to define a grammar for special language for certain reasons. After defining the syntax of this language, you need to build an interpreter to interpret the language and do actions accordingly. Interpreter Design Pattern help you to define a well structure object oriented classed to parse your expressions against the new Read More …

Proxy Design Pattern

Introduction: Sometimes you become into a case where you does not or can not reference an object directly, but you still want to interact with that object to do some job. The intent of the proxy design pattern is to control access to an object by providing placeholder for it. Below example will make the Read More …

Flyweight Design Pattern

Introduction: Flyweight design pattern target to minimizes the memory usage by sharing as much data as possible with other similar objects. It is very useful when have large amount of objects in memory which have lot of similar values. by sharing the similar values between all the objects, memory usage will be much less. Example: Read More …

Façade (Facade) Design Pattern

Introduction: Façade is one of the most used design patterns on software industry. Basically it is about providing a simple interface for large body of code, like class library and it will help you on : Make large body of code easier to be understand. Make client code more readable. Reduce dependency of client code Read More …

Composite Design Pattern

Introduction: Sometimes you want to treat a group of objects as a single instance. Composite design pattern is aiming to compose object into a structure of tree to represent part-whole hierarchy structures. A simple example of this design pattern is directory structure.. Each directory might contains some entries and those entries might be a directory. Read More …

Bridge Design Pattern

Introduction: Sometimes you want to decouple the abstraction from its implementation so both of them can be vary independently. Bridge design pattern helps you in implementing this decoupling easily. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes Example:     static void Main() { // Create Record Set Read More …