请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

nemanjarogic/DesignPatternsLibrary: A comprehensive design patterns library impl ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

nemanjarogic/DesignPatternsLibrary

开源软件地址(OpenSource Url):

https://github.com/nemanjarogic/DesignPatternsLibrary

开源编程语言(OpenSource Language):

C# 100.0%

开源软件介绍(OpenSource Introduction):

Design Patterns Library

32 Design Patterns • 65 moderately realistic examples

What are Design Patterns?

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. In addition, design patterns allow developers to communicate using well-known, well understood names for software interactions.

Know when to use a certain design pattern, and when not to. No design pattern is a 42 - the answer to life, the universe and everything. There are situations in which every design pattern easily becomes an antipattern.

Design Pattern Types

Design patterns can be separated into three main categories:

  • Creational

Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

  • Structural

Structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships among entities. Structural patterns are concerned with how classes and objects are composed to form larger structures.

  • Behavioral

Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just the patterns of objects or classes but also the patterns of communication between them.

What this repository contains?

This repository contains a comprehensive design patterns library implemented in C#, which covers various design patterns from the most commonly used ones (Gang of Four) to the lesser-known ones. It enables you to get familiar with and learn design patterns through moderately realistic examples.

Design Pattern Type Description Introduction
Abstract Factory Creational Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Adapter Structural Allows objects with incompatible interfaces to collaborate.
Bridge Structural Lets you split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other.
Builder Creational Lets you construct complex objects step by step. The pattern allows you to produce different types and representations of an object using the same construction code.
Chain Of Responsibility Behavioral Lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain.
Command Behavioral Turns a request into a stand-alone object that contains all information about the request. This transformation lets you parameterize methods with different requests, delay or queue a request’s execution, and support undoable operations.
Composite Structural Lets you compose objects into tree structures and then work with these structures as if they were individual objects. Treat individual objects and compositions of objects uniformly.
Decorator Structural Lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. Extend or alter the functionality of objects at runtime.
Facade Structural Provides a simplified interface to a library, a framework, or any other complex set of classes. This makes a complex body of code simpler to use and consume.
Factory Method Creational Provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
Flyweight Structural Lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object. It reduces storage costs for a large number of objects.
Iterator Behavioral Lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.)
Mediator Behavioral Lets you reduce chaotic dependencies between objects. The pattern restricts direct communications between the objects and forces them to collaborate only via a mediator object.
Memento Behavioral Lets you save and restore the previous state of an object without revealing the details of its implementation.
Observer Behavioral Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they are observing.
Prototype Creational Lets you copy existing objects without making your code dependent on their classes.
Proxy Structural Lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.
Singleton Creational Ensures that a class has only one instance, while providing a global access point to this instance.
State Behavioral Lets an object alter its behavior when its internal state changes. It appears as if the object changed its class. This pattern is close to the concept of finite-state machines.
Strategy Behavioral Enables an algorithm’s behavior to be selected at runtime. The pattern defines a family of algorithms, encapsulates each algorithm and makes the algorithms interchangeable within that family. In other words, this pattern is used when we have multiple algorithms for a specific task and we want the client to decide which actual implementation should be used at runtime.
Template Method Behavioral Defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps of the algorithm without changing its structure.
Visitor Behavioral A way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying the structures.

Extra content

Design Pattern Type Description
Event Aggregator Behavioral Channel events from multiple objects into a single object to simplify registration for clients.
Interpreter Behavioral Defines a grammatical representation for a language and provides an interpreter to evaluate sentences in a language.
Lazy Load Data Access Defers initialization of an object until the point at which it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used.
Null Object Behavioral Encapsulates the absence of an object by providing a substitutable alternative that offers suitable default do nothing behavior.
Repository Data Access Encapsulates all the minutiae of data access. Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
Rules Behavioral Separates the logic of each individual rule and its effects into its own class. Separates the selection and processing of rules into a separate Evaluator class.
Service Locator Architectural Improves the modularity of your application by removing the dependency between the client and the implementation of an interface. Encapsulates the processes involved in obtaining a service with a strong abstraction layer. This pattern uses a central registry known as the service locator which on request returns the information necessary to perform a certain task.
Specification Architectural Separates the statement of how to match a candidate, from the candidate object that it is matched against. Specification design pattern allows us to check whether our objects meet certain requirements. Through this design pattern, we can reuse expression specifications and combine those specifications to easily question whether more complex requirements are satisfied or not.
Unit Of Work Data Access Maintains a list of objects affected by a business transaction and coordinates the writing out of changes.

I want to give credit to Refactoring.Guru for amazing content about design patterns. I highly recommend checking it for more details on design patterns theory.

The examples that are used to demonstrate design patterns usage are a mix of my own ideas and ideas adapted from various resources. If you prefer learning by watching courses great content can be found at Pluralsight.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
sshahine/JFoenix: JavaFX Material Design Library发布时间:2022-08-15
下一篇:
Kotlin/kotlinx.coroutines: Library support for Kotlin coroutines发布时间:2022-08-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap