microservice resiliency patterns circuit
23) Strategy pattern
类别: Behavior Pattern 问题: 方案: 示例: public class StrategyPatternDemo { public static void main(String[] args) { Context context = new Context(new Operati ......
24) Template pattern
类别: Behavior Pattern 问题: 方案: 示例: public class TemplatePatternDemo { public static void main(String[] args) { Game game = new Cricket(); game.play(); S ......
25) Visitor pattern
类别: Behavior Pattern visit ['vizit] the act of going to see some person or place or thing for a short time 问题: 方案: 示例: public class VisitorPatternDemo ......
26) MVC Pattern
类别: 问题: 方案: 示例: public class MVCPatternDemo { public static void main(String[] args) { // fetch student record based on his roll no from the database ......
22) Null Object pattern
类别: 问题: 方案: 示例: public class NullObjectPatternDemo { public static void main(String[] args) { Animal animal; animal = getAnimal("cat"); animal.makeSou ......
27) Business Delegate Pattern
类别: 问题: 方案: public class BusinessDelegatePatternDemo { public static void main(String[] args) { BusinessDelegate businessDelegate = new BusinessDelega ......
11) Facade Pattern
类别: Structural Pattern 问题/动机: 系统非常复杂 隐藏复杂细节,提供简单界面 方案: 示例: /* Complex parts */ public class FacadePatternDemo { public static void main(String[] args) ......
12) Flyweight Pattern
类别: Structural Pattern 问题/动机: 假若绿色是相同部分,占用1M内存 ,如果提取出来,众对象共享其内容,只占1M内存 ,否则占10M ,且随着对象增多,占用越来越多内存 ,无疑是浪费资源 A flyweight is an object that minimizes memo ......
13) Proxy Pattern
类别: Structural Pattern 问题: 操纵一个对象时碍手碍脚,与装饰者模式不同之处: 装饰者是接口方法,授权小 代理则是整个类,授权大 方案: 示例: public class ProxyPatternDemo { public static void main(final Stri ......
15) Command pattern
类别: Behavioral Pattern 问题: 方案: 示例: import java.util.ArrayList; import java.util.List; public class CommandPatternDemo { public static void main(String ......
16) Interpreter pattern
类别: behavioral pattern 问题: Polish notation https://en.wikipedia.org/wiki/Polish_notation Abstract syntax tree https://en.wikipedia.org/wiki/Abstract_s ......
17) Iterator pattern
类别: behavioral pattern 问题: Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. 方案 ......
14) chain of responsibility pattern
类别: behavioral pattern 问题: 高耦合,不灵活 if(){ }else if(){ }else if(){ } ... 方案: 示例: public class ChainOfResponsibilityPattern { public static void main(Str ......
cpp: Visitor Pattern
/*****************************************************************//** * \file Gold.h * \brief 访问者模式 Visitor Pattern C++ 14 行为模式 * 2023年6月8日 涂聚文 Geovi ......
cpp: Chain Of Responsibility Pattern
/*****************************************************************//** * \file PayrollProcessing.h * \brief 责任链模式Chain Of Responsibility Pattern 亦称: 职 ......
立即报名 | Microservices June 微服务之月再度开启
> 原文作者:NGINX > > 原文链接:[立即报名 | Microservices June 微服务之月再度开启](https://www.nginx.org.cn/article/detail/12622) > > 转载来源:NGINX 官方网站 ![](https://oscimg.osch ......
cpp: Memento Pattern
/*****************************************************************//** * \file ActorMemento.h * \brief 备忘录模式 Memento Pattern亦称:快照、Snapshot、Memento C++ ......
compiler expression pattern match
编译器中经常需要用到pattern match。 那么如何实现呢? 比较直观的方法是使用递归。 以pattern match: y= a * (b + c) 为例。 首先,将其解析成一个抽象语法树:* a + b c 其次,递归match: match(y, pattern) => match(y, ......
3) Singleton pattern
类别: creational Pattern 问题/动机: 反复创建对象开销巨大耗时长消耗内存/重复使用 方案: 示例: // 1 class Demo1 { public final static Demo1 INSTANCE = new Demo1(); private Demo1() { if ......
4) Builder Pattern
类别: Creational pattern 问题: 构造函数入参超长易变 方案: 示例: public class BuilderPatternDemo { public static void main(String[] args) { Car.Builder builder = new Car ......
5) Prototype Pattern
类别: Creational Pattern 问题: 不想修改原对象状态,但需要依据当前数据进行计算 方案: 示例: public class PrototypePattern { public static void main(String[] args) { Movie movie = new ......
6) Adapter Pattern
类别: Structural Pattern 问题: 什么是接口?按照标准提供服务,其他想要使用该接口的要按照该标准接入服务 什么是依赖?持有目标对象,拥有使用权(A use B) 数据线?数据线按USB标准接入充电宝,通过lightning 提供充电服务 手机?通过lightning标准接入数据线 ......
7) Bridge Pattern
类别: Structural Patterns 问题: 连连看的问题 不使用桥接,要写81 个类,使用桥接,只需要18个类 方案: 示例: public class BridgePatternDemo { public static void main(String[] args) { Somebo ......
9) Composite Pattern
类别: Structual Pattern 问题: 方案: 示例: import java.util.ArrayList; import java.util.List; public class CompositePatternDemo { public static void main(Strin ......
10) Decorator Pattern
类别: Structural Pattern 问题: 在不改变接口的前提下增加额外的服务 方案: 示例: public class DecoratorPatternDemo { public static void main(String[] args) { Shape circle = new C ......
1) Factory method pattern
类别: Creational Pattern 问题/动机 如何创建一套子类的问题(父类引用指向子类实例) 情形1:一个方法返回一个具体的子类 极端情况:1万个子类需要一万个方法吗 极端情况:如过再扩展一万个子类,还需要再增加一万个方法吗 极端情况:虽然有一万个子类,但只需要用到其中一个,其他9999 ......
2) Abstract Factory Pattern
类别: Creational Pattern 问题/动机: 如何创建一套父类的问题 情形一:混淆,且不能察觉 // 下面这个方法本来是要建造一辆宝马汽车,但是因为零部件太多,粗心大意误用了奔驰的零件。 public Car createBMWCar(){ Part1 p1 = new com.bmw ......
8) Filter/Criteria Pattern
类别: Structual Pattern 问题: 方案: 示例: import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class Crit ......
cpp: Mediator Pattern
/*****************************************************************//** * \file ControlParent.h * \brief MediatorPattern 中介者模式 亦称: 调解人、控制器、Intermediary ......
cpp: Bridge Pattern
/*****************************************************************//** * \file Gold.h * \brief 桥接模式 Bridge Pattern C++ 14 * 2023年6月3日 涂聚文 Geovin Du Vi ......