Skip to content

Latest commit

 

History

History
83 lines (58 loc) · 3.54 KB

README.md

File metadata and controls

83 lines (58 loc) · 3.54 KB

Design Patterns in C#

This repository is part of the Refactoring.Guru project.

It contains C# examples for all classic GoF design patterns. Each pattern includes two examples:

  • Structural examples show the internal structure of patterns with detailed comments.
  • RealWold examples show how the patterns can be used in a real-world C# application.

Status & Roadmap

This repository is in the very initial state at the monent. Missing examples:

  • Factory-method: RealWorld
  • Abstract-factory: RealWorld
  • Builder: RealWorld
  • Prototype: RealWorld
  • Singleton: RealWorld
  • Adapter: RealWorld
  • Bridge: RealWorld
  • Composite: RealWorld
  • Decorator: RealWorld
  • Facade: RealWorld
  • Flyweight: RealWorld
  • Proxy: RealWorld
  • Chain-of-responsibility: RealWorld
  • Command: RealWorld
  • Iterator: RealWorld
  • Mediator: RealWorld
  • Memento: RealWorld
  • Observer: RealWorld
  • State: RealWorld
  • Strategy: RealWorld
  • Template-method: RealWorld
  • Visitor: RealWorld

Requirements

Most examples are console apps built using .NET Core.

For the best experience, we recommend working with examples with these IDEs:

Contributor's Guide

We appreciate any help, whether it's a simple fix of a typo or a whole new example. Just make a fork, do your change and submit a pull request.

Here's a style guide which might help you to keep your changes consistent with our code:

  1. All code should follow the Microsoft C# code style guide.

  2. Try to hard wrap the code at 80th's character. It helps to list the code on the website without scrollbars.

  3. The actual examples should be represented by projects with the following naming convention: RefactoringGuru.DesignPatterns.{PatternName}.{ExampleName}.

  4. Aim to put all code within one file. We realize that it's not how it supposed to be done in production. But it helps people to better understand examples, since all code fits into one screen.

  5. Comments may or may not have language tags in them, such as this:

     /// <summary>
     /// EN: All products families have the same varieties (MacOS/Windows).
     ///
     /// This is a MacOS variant of a button.
     ///
     /// RU: Все семейства продуктов имеют одни и те же вариации (MacOS/Windows).
     ///
     /// Это вариант кнопки под MacOS.
     /// </summary>

    This notation helps to keep the code in one place while allowing the website to generates separate versions of examples for all listed languages. Don't be scared and ignore the non-English part of such comments. If you want to change something in a comment like this, just do it. Even if you do it wrong, we'll tell you how to fix it during the Pull Request.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Creative Commons License