Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design Patterns

Build and Test

This repository contains a .NET 10 solution implementing various design patterns in C#. Each design pattern is implemented in a separate console project within the solution.

Each project folder has its own README.md explaining what problem the pattern solves and when to reach for it.

Project Structure

The repository is organized as follows:

DesignPatterns/
│
├── SingletonPattern/
│   ├── Program.cs
│   └── ...
│
├── FactoryPattern/
│   ├── Program.cs
│   └── ...
│
├── BuilderPattern/
│   ├── Program.cs
│   └── ...
│
├── ...

Each folder represents a design pattern and contains a console project that implements that specific pattern.

How to Run

  1. Open a terminal and navigate to the directory of the project you want to run. For example, to run the Singleton pattern:
cd /path/to/DesignPatterns/SingletonPattern
  1. Build the project using the dotnet build command:
dotnet build
  1. Once built, run the program using the dotnet run command:
dotnet run

This command will build the project if necessary and then execute the application.

If you want to run a specific project instead of all projects in the solution, you can specify the project name after the dotnet run command. For example:

dotnet run --project SingletonPattern

This will run only the SingletonPattern project. Replace SingletonPattern with the name of the project you want to run.

Implemented Design Patterns

Creational

  1. Singleton
  2. Factory Method
  3. Builder
  4. Prototype

Structural

  1. Adapter
  2. Decorator
  3. Facade
  4. Bridge
  5. Composite
  6. Proxy

Behavioral

  1. Observer
  2. Command
  3. Strategy
  4. State
  5. Chain of Responsibility
  6. Template Method
  7. Iterator

Other

  1. Dependency Injection (not a GoF pattern, but common enough in C# to include)

Each design pattern is implemented in its own project and contains code examples demonstrating its usage.

Combined Example

Every project above shows one pattern in isolation. OrderProcessingExample shows Builder, Strategy and Observer working together in a single, small order-processing scenario — see its README for how they fit together.

dotnet run --project OrderProcessingExample

Running the Tests

The DesignPatterns.Tests project covers all 18 patterns and the combined example above. Run it with:

dotnet test DesignPatterns.sln

CI also runs dotnet format --verify-no-changes to catch style issues, and publishes a coverage summary to each run's job summary on GitHub Actions.

License

This project is licensed under the MIT License.

About

Classic GoF design patterns in C# — 18 patterns (creational, structural, behavioral) plus dependency injection, with xUnit tests and CI.

Topics

Resources

Stars

18 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages