Introduction – C# Object-oriented Design Patterns Full Tutorial

There are many different types of programming languages such as Functional, Procedural, Object-Oriented, Scripting, and Logic programming languages. Every type of programming language uses some sort of design patterns or strategies to solve common problems. In this context, Design Patterns are commonly and repeatedly used solutions for the design problems that software programmers face again and again. Design Patterns have been there for a long, but the famous book, “Design Patterns – Elements of Reusable Object-Oriented Software” by GoF classified 23 Design Patterns that are considered the foundation of Design Patterns for Object-Oriented Programming languages and widely used to solve common design problems. According to the book, every design pattern has four common elements that include the “Name” of the Pattern, the “Problem” to which it is applied, the “Solution” of the problem, and the consequences that are the result of the trade-off applying the Design Pattern to solve the problem.

Video Tutorial – Introduction to C# Object-Oriented Design Patterns

Classification

The Object-Oriented Design Patterns are classified into three major categories. These design patterns differ in various aspects such as scalability, and application. 

  • Creational Patterns
  • Structural Patterns
  • Behavioral Patterns

Creational Design Patterns

  • Abstract Factory: Help produce objects from related classes without specifying their concrete classes. 
  • Builder: Help build objects with different representations.
  • Factory Method: Defines a way to create an object where subclasses decide what object is going to be created.
  • Prototype: Create clones or copies of objects without depending on classes.
  • Singleton: Help maintain only a single instance or object of a class.

Structural Design Patterns

  • Adapter: Help objects to collaborate with different incompatible interfaces. It helps classes to work together through interfaces that they couldn’t otherwise.
  • Bridge: Bridges between the Object’s Interface (Abstraction) and its implementation. This design pattern provides a decoupling of abstraction from its implementation.
  • Composite: Help transform classes into a tree structure and utilize the structure as standalone objects.  It helps transform objects into a part-whole hierarchy.
  • Decorator: Help wrap objects with new behavior by adding new responsibilities to the objects.  Provides a flexible way for sub classing to extend the functionality.
  • Façade: Provides a common and unified interface or class to interact with a sub-system of classes. It provides an easier way to interact with subsystems.
  • Flyweight: Help share the common state of objects between different objects for efficient use of memory.
  • Proxy: Help provide a proxy object that controls the access to the original object.

Behavioral Design Patterns

  • Chain of Responsibility: Help pass requests along a chain of objects or handlers that decide to handle the request or pass it to the next object in the given chain.
  • Command: handles the request as a Stand-alone object with state and responsibility
  • Interpreter: Help include language elements into a program.
  • Iterator: Help traverse a collection sequentially without exposing its underlying structure. 
  • Mediator: Help reduce object dependencies and provide simplified communication between those objects.
  • Memento: Save and retrieve the internal state of objects.
  • Observer: Help implement a subscription mechanism to observe the changes in the object state.
  • State: Help alter an object’s behavior when its state changes.
  • Strategy: Help incorporate different algorithms into a class that objects can use according to needs. 
  • Template Method: Help implement algorithms in steps and specialize in child classes. Visitor: Help you manage different algorithms separately from objects.
Views: 1

Leave a Reply

Your email address will not be published. Required fields are marked *