Posted by Wei on 2018-11-12, Last Modified on 2025-04-23
The adapter design pattern solves problems like:
Often an (already existing) class can’t be reused only because its interface doesn’t conform to the interface clients require.
通过尽可能共享对象中的数据来实现对内存的最小化使用,这就是享元模式的动机。
一个典型的例子是:在Word中,对字符的图形化展现。如果每一个显示的字符都对应一个独立的对象,这将会消耗大量的内存。取而代之,位于文档中不同位置的相同字符会共享大部分属性,而只有字符位置这样的属性才需要被单独保存。
Posted by Wei on 2018-11-11, Last Modified on 2025-04-23
观察者模式(Observer Pattern)定义了一种一对多的依赖对象关系,使得当那一个对象状态发生改变时,依赖它的多个对象均能得到通知并自动更新(做出相应反应)。
Chain of Responsibility is a behavioral design pattern that 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.
Posted by Wei on 2018-11-11, Last Modified on 2023-08-23
🐒 Software engineer | 📷 Photographer | 👹 Urban explorer