This repository contains examples of various design patterns implemented in C#.
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.
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.
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.
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.
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.
Each example file can be compiled and executed separately to see the pattern in action.
To run the examples:
- Clone this repository.
- Navigate to the directory containing the example files.
- Compile the C# files using a C# compiler.
- Execute the compiled program.