Skip to content

sumit-tft/design-pattern-dot-net

Repository files navigation

Design Patterns Examples

This repository contains examples of various design patterns implemented in C#.

Patterns Implemented

1. Singleton Pattern

The Singleton Pattern ensures that a class has only one instance and provides a global point of access to that instance.

Example: A logging system where only one instance of the logger is required throughout the application.

2. Factory Method Pattern

The Factory Method Pattern defines an interface for creating objects, but allows subclasses to alter the type of objects that will be created.

Example: A vehicle manufacturing system where different factories produce different types of vehicles.

3. Abstract Factory Pattern

The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.

Example: A user interface toolkit where different factories produce UI components with consistent themes.

4. Builder Pattern

The Builder Pattern separates the construction of a complex object from its representation, allowing the same construction process to create different representations.

Example: A meal ordering system at a restaurant where different types of meals can be constructed with various components.

5. Prototype Pattern

The Prototype Pattern creates new objects by copying an existing object, known as a prototype.

Example: A drawing application where shapes can be cloned to create new shapes.

Usage

Each example file can be compiled and executed separately to see the pattern in action.

To run the examples:

  1. Clone this repository.
  2. Navigate to the directory containing the example files.
  3. Compile the C# files using a C# compiler.
  4. Execute the compiled program.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages