DotNet7-DesignPatterns

所属分类:.net编程
开发工具:C#
文件大小:0KB
下载次数:0
上传日期:2023-08-04 07:16:23
上 传 者sh-1993
说明:  在.NET7中玩一些设计模式,
(Playing around with some Design Patterns in .NET7,)

文件列表:
Behavioural/ (0, 2023-08-11)
Behavioural/Strategy/ (0, 2023-08-11)
Behavioural/Strategy/src/ (0, 2023-08-11)
Behavioural/Strategy/src/Implementation.cs (2999, 2023-08-11)
Behavioural/Strategy/src/ImplementationSalesTax.cs (3309, 2023-08-11)
Behavioural/Strategy/src/Strategy.csproj (206, 2023-08-11)
Behavioural/Strategy/strategy.tests.unit/ (0, 2023-08-11)
Behavioural/Strategy/strategy.tests.unit/ImplementationSalesTaxTests.cs (729, 2023-08-11)
Behavioural/Strategy/strategy.tests.unit/ImplementationTests.cs (739, 2023-08-11)
Behavioural/Strategy/strategy.tests.unit/Strategy.Tests.Unit.csproj (1009, 2023-08-11)
Behavioural/Strategy/strategy.tests.unit/Usings.cs (19, 2023-08-11)
Creational/ (0, 2023-08-11)
Creational/FactoryMethod/ (0, 2023-08-11)
Creational/FactoryMethod/src/ (0, 2023-08-11)
Creational/FactoryMethod/src/FactoryMethod.csproj (239, 2023-08-11)
Creational/FactoryMethod/src/Implementation.cs (3340, 2023-08-11)
Creational/FactoryMethod/src/Program.cs (426, 2023-08-11)
Creational/Singleton/ (0, 2023-08-11)
Creational/Singleton/src/ (0, 2023-08-11)
Creational/Singleton/src/Implementation.cs (609, 2023-08-11)
Creational/Singleton/src/Singleton.csproj (206, 2023-08-11)
Creational/Singleton/src/Singleton/ (0, 2023-08-11)
Creational/Singleton/src/Singleton/ImplementationNonThreadSafe.cs (609, 2023-08-11)
Creational/Singleton/src/Singleton/ImplementationThreadSafe.cs (1791, 2023-08-11)
Creational/Singleton/src/Singleton/Program.cs (863, 2023-08-11)
Creational/Singleton/src/Singleton/Singleton.csproj (239, 2023-08-11)
DesignPatterns.sln (5138, 2023-08-11)

# Creational patterns Deal with object creation Abstract the object instanttiation process Help make your system independent of how its objects are created, composed and represented Five patterns: - Abstract factory, builder, factory method, prototype, singleton # Structural patterns: Deal with ways to define relations between classes or objects Concerned with how classes and objects are composed to form larger structures Seven patterns: - Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy # Behavioural patterns: Deal with ways to communicate between classes or objects Characterize complex control flow that is difficult to follow at runtime Let you concentrate on the way objects are interconnected Eleven patterns: - Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor # Object Oriented Principles Two important object oriented principles are followed by the gang of four in their design patterns. 1) Program to an interface, not an implementation Clients remain unaware of the specific types of objects they use Clients remain unaware of the classes that implement these objects, they only know the interface Can also be implemented with the abstract class language feature, in general: * use an abstract base class when you need to provide some basic functionality that can potentially be overriden, eg: can declare some default functionality that is usable or overridable by all subclasses * use an interface when you only need to specify the expected functionality of a class Commonly correlates to adhering to the open/closed principle (SOLID) 2) Favor object composition over class inheritance Concern reusing functionality - Class inheritance (white-box reuse): Let's you define the implementation of one class in terms of another's You create a subclass of a base or parent class (inherit the parent class) - Object composition (black-box reuse): New functionality is obtained by assembling or composing objects to get more complex functionality Internal details of objects are not visible to the composing class Commonly relates to the single responsibility principle (SOLID) - A class should have one and only one reason to change

近期下载者

相关文件


收藏者