A set of labs to understand and practice design patterns (under development).
Read it in other languages: English, Português (Brasil)
This is a repository of the descriptions, UML class diagrams and examples of the design patterns, based on the 'Head First Design Patterns' book but adapted to C# language (.NET 5).
The UML Class Diagrams were built with Astah UML.
The design patterns are guided by following principles:
- Identify the aspects of your application that vary and separate them from what stays the same.
- Principle of Dependency Inversion: Program to an interface, not an implementation.
- Favor composition above inheritance (HAS-A can be better than IS-A).
- Strive for loosely coupled designs between objects that interact.
- Open-Closed Principle: Classes should be open for extension, but closed for modification.
- Principle of Least Knowledge: Talk only to your immediate friends.
- Hollywood Principle: Don't call us, we'll call you.
Padrão | Descrição |
---|---|
ADAPTER | Converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. |
COMMAND | Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log request, and support undoable operations. |
DECORATOR | Attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. |
FACADE | Provides an unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. |
FACTORY | Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. |
OBSERVER | Defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically. |
SINGLETON | Ensures a class has only one instance, and provides a global point of access to it. |
STRATEGY | Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. |
TEMPLATE METHOD | Defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure. |
If you want to help to translate the project, include other languages or warn me about some bug you're welcome! Please follow our code of conduct.
- @filimor
- @bethrobson (Book's repository)
This project is licensed under the MIT License - see the LICENSE.md file for details.