Design Patterns
Design Patterns
2022/06/20 (增加連結)
2022/12/13 (增加投影片)
介紹
Software Architecture: The Most Important Architectural Patterns You Need to Know
Layered Architecture
Pipe and Filter
Client Server
Model View Controller
Event Driven Architecture
Microservices Architecture
Software Architecture - The Difference Between Architecture and Design
Software Architecture Patterns
Serverless Architecture
Event-Driven Architecture
Microservices Architecture
Design Patterns
Factory Pattern
Adapter Pattern
Software design pattern (wikipedia)
Is It Time to Get Over Design Patterns?
A brief history of design patterns
The cost of complexity
Ambiguous extensibility
Mismatching and bad fits
The antidote: Be simple
Patterns are a design language
The real value of design patterns is not prescriptive (telling you what to do). It’s descriptive (telling others what you’ve done). Design patterns aren’t recipes. They’re a language.
My Top 4 Patterns for Writing Simple Code
Pattern 1: Abstract Factory
Pattern 2: Delegator
Pattern 3: Builder / Named Params
Pattern 4: Enricher
This pattern isn’t in the G-o-4 book, but it’s most closely related to chain of responsibility and the template method
91 點部落
[ASP.NET]重構之路系列v6 –抽象來看程式是否符合DRY原則
Template Method
[.NET]重構之路系列v13–避免直接相依外部組件,以加解密為例
Adapter
SOLID (詳參: SOLID:五則皆變 )
Single-Responsibility
Open-Closed Principle
Decouple External Services From Core UI Code : And reduce the size of your future PRs with the Open/Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency-Inversion Principle
5 Problems Faced When Using SOLID Design Principles — And How To Fix Them
Code Principles Every Programmer Should Follow: YAGNI, Law of Demeter, Single Responsibility and other useful principles for better coding.
設計模式的逆襲 (by Teddy Chen)
Agile software development (by Robert C. Martin) & Object-Oriented Software Construction (by Bertrand Meyer)
Teddy建議學習順序為:
Builder、Abstract Factory、Facade、Proxy、State、Template Method
Bridge、Strategy、Visitor、Mediator、Iterator、Prototype
Decorator、Flyweight、Chain of Responsibility、Interpreter、Memento
Patterns relying on abstract coupling
就是『program to an interface, not an implementation』
Creational patterns
Factory Method、Builder、Prototype
Software Design Patterns: Factories Are Not Builders : The difference between Factory and Builder design patterns
Structural patterns
Bridge、Adapter、Proxy
Behavioral patterns
State、Observer、Command、Visitor、Interpreter、Mediator、Strategy
Patterns based on recursive structures
這一類的 patterns 就是有遞迴結構
Composite(S), Chain of Responsibility(B), Decorator(S)
Other patterns
Abstract Factory(C), Flyweight(S), Singleton(C), Template Method(B)
Force
Creational Design Patterns
Creational Patterns要解決什麼問題(上)?
直接在需要產生物件的時候把物件給new出來
用Reflection的方式來產生物件
用Simple Factory pattern
Creational Patterns要解決什麼問題(中)?
用clone(Prototype pattern)的方式來產生物件。
用Singleton pattern
用Object Pool pattern
Creational Patterns要解決什麼問題(下)?
用Factory Method pattern
Simple Factory Method
Polymorphic Factory Method
Class Factory Method (Static Factory)
用Abstract Factory pattern
用Builder pattern
Structural Design Patterns
Behavioral Design Patterns
Modern-Day Architecture Design Patterns for Software Professionals
Circuit Breaker
Command and Query Responsibility Segregation (CQRS)
Event Sourcing
Sidecar
Backend-for-Frontend
Strangler
3 Useful Design Patterns I Use Frequently
Strategy Pattern
Publish-Subscribe Pattern
Proxy Pattern
The 7 Most Important Software Design Patterns
Singleton
Factory Method
Strategy
Observer
Builder
Adapter
State
Java
8 design patterns that every developer should know (Java)
Singleton
Initialization On Demand Holder
The Strategy and the Factory Pattern
Fluent Builder
Chain of Responsibility
Template Method
State Pattern
Factory
Singleton
Adapter
Decorator
Facade
Observer
Singleton
Factory
Decorator
Composite
Adapter
Prototype
Facade
Proxy
Iterator
JavaScript
Basic Building Blocks of JavaScript Design Patterns
Abstraction
Encapsulation
Polymorphism
Inheritance
Creational Design Patterns
Constructor Pattern
Factory Pattern
Prototype Pattern
Singleton Pattern
Structural Design Patterns
Adapter Pattern
Composite Pattern
Decorator Pattern
Facade Pattern
Flyweight Pattern
Proxy Pattern
Behavioral Design Patterns
Chain of Responsibility Pattern
Command Pattern
Iterator Pattern
Mediator Pattern
Observer Pattern
State Pattern
Strategy Pattern
Template Pattern
Understanding Design Patterns in JavaScript
Module Pattern
Revealing Module Pattern
Singleton Pattern
Factory Pattern
Decorator Pattern
Design patterns in modern JavaScript development
Singleton pattern
Observer pattern
Facade pattern
Commonly Used Design Patterns in JavaScript
Singleton
Iterator
Factory
Singleton
Factory
Iterator
Decorator
Constructor Pattern
Module Pattern
Revealing Module Pattern
Singleton Pattern
Observer Pattern
Publish/Subscribe Pattern
Mediator Pattern
Prototype Pattern
Command Pattern
Facade Pattern (structural pattern)
Factory Pattern (creational pattern)
Mixin Pattern
4 Useful JavaScript Design Patterns You Should Know
Strategy Pattern
Publish–subscribe pattern
Decorator Pattern
Chain of Responsibility Pattern
4 JavaScript Design Patterns You Should Know
Module
Prototype
Observer
Singleton
A LOOK AT POPULAR JAVASCRIPT DESIGN PATTERNS
The Module Design Pattern
The Singleton Design Pattern
The Mediator Design Pattern
JavaScript Design Patterns — Composition, Inheritance, and Configuration
Dependency Injection
Adapter
Bridge
Builder
Command
Composite
Decorator
Facade
Factory
Iterator
Mediator
Memento
Module
JavaScript Design Pattern — Module Pattern
What is a Closure?
Module Pattern
The Usage With IIFE
The Usage With Export Keyword
The Usage With Class
Bonus: The Usage With TypeScript
Null Object
Design Patterns: Null Object: Avoid conditional complexity using this pattern
Observer
Prototype
Proxy
Publisher/Subscriber
JavaScript Design Patterns Part 2: The Publisher/Subscriber Pattern
Implementing a Messaging Service in Plain JavaScript : implementing a Messaging Service JavaScript module to handle communication between components implementing the Messaging Pattern, more specifically the publish/subscribe messaging pattern.
State
Strategy
Typescript
Adapter
Bridge
Command
Decorator
Composite
Factory
Facade
Singleton
Strategy
React
HOC Pattern (Higher Order Component Pattern)
Contianer and Presentational Components Pattern
回應中: One thing to add is that with hooks, Container/Presentation pattern is not recommended anymore. This pattern strongly couples logic into our components.
Provider Pattern
Hooks Pattern
Container
Presentational
Higher order components (HOC’s)
Render callback
React patterns you should know
Global app data and cross-cutting concerns
react-redux / react-router
Provider
Higher Order Components (HOCs)
Context API
Render props
How To Master Advanced React Design Patterns — Compound Components
Kotlin
Common Design Patterns for Android with Kotlin
Creational
Builder
Dependency Injection
Singleton
Structural
Adapter
Facade
Behavioral
Command
Observer
Model View Controller
Model View ViewModel
Clean Architecture
Android (Java)
Android 常用的 Design Pattern I (Java)
Adapter
Singleton
Bridge
Observer
Factory Method
Android 常用的 Design Pattern II (Java)
Composite
Chain of Responsibility
Decorator
Template Method
Swift
Top 5 Design Patterns in Swift for iOS App Development
Builder
Adapter
Decorator
Facade
Template Method
.Net
Learning Design Pattern in 30 real-case practices (c# & Python)
當一開始的時候,先利用文字檔來儲存log,如果一開始,多花一點小功夫,多寫一個interface(ILogger)
//For current iteration
ILogger logger = new TextLogger();
(new MyTask(logger)).Run();
等準備好了,只要改這個部分,其他的就不需要動了
//Refine in next iteration
ILogger logger = new DatabaseLogger();
(new MyTask(logger)).Run();
職場第一條規則:事情不要接了傻傻做,而是要交給負責的人! (Chain of Responsibility 職責鍊模式)
DBA說換資料庫的帳號密碼,結果我花了一天改連線資訊$#&@#! (Factory 工廠模式)
Static factory
Abstract factory
Generic factory (C#)
[Design Pattern實例] 在策略模式使用委派解耦合 (Strategy)
網頁上遺漏了部分的程式碼:
[HttpPost]
public IActionResult Index(string fileType, FreightOrder fo)
{
ModelState.Clear();
IFoStrategy stg = null;
if (fileType.Equals("1"))
{
stg = new FoStrategyAppend();
ViewBag.Strategy = "採用策略:累加原單之數量";
}
else
{
stg = new FoStrategyReplace();
ViewBag.Strategy = "採用策略:覆蓋原單之數量";
}
stg.Query = DataAccessService.Query;
stg.Update = DataAccessService.Update;
updateFreightOrder(fo, stg);
return View(fo);
}
Design Pattern Implementation using C#
Singleton Design Pattern
Factory Design Pattern
Factory Method Design Pattern
Abstract Factory Design Pattern,
Builder Design Pattern,
Prototype Design Pattern
Adapter Design Pattern
Bridge Design Pattern
Decorator Design Pattern
Composite Design Pattern
Flyweight Design Pattern
Memento Design Pattern
Mediator Design Pattern
Observer Design Pattern
Iterator Pattern