From abb354ebe0f20481aef699547bb133b787caf11b Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Sun, 7 Sep 2025 00:08:35 +0800 Subject: [PATCH] fix : Document --- document/decorator.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/document/decorator.md b/document/decorator.md index 2f0fe76..12c5278 100644 --- a/document/decorator.md +++ b/document/decorator.md @@ -16,10 +16,10 @@ 装饰器模式通常包含以下角色: -- Component(抽象组件):定义对象接口,可以动态添加职责 -- ConcreteComponent(具体组件):定义具体对象 -- Decorator(抽象装饰类):继承/实现Component,并持有Component引用 -- ConcreteDecorator(具体装饰类):向组件添加具体职责 +- Component(抽象组件):定义对象接口,可以动态添加职责 +- ConcreteComponent(具体组件):定义具体对象 +- Decorator(抽象装饰类):继承/实现Component,并持有Component引用 +- ConcreteDecorator(具体装饰类):向组件添加具体职责 #### 应用场景 @@ -35,17 +35,17 @@ #### 优缺点 ##### 优点 -- 比继承更灵活(可以在运行时添加或移除功能) +- 比继承更灵活(可以在运行时添加或移除功能) - 避免子类爆炸问题 -- 符合开闭原则(对扩展开放,对修改关闭) +- 符合开闭原则(对扩展开放,对修改关闭) - 可以嵌套多个装饰器 ##### 缺点 - 会产生许多小对象,增加系统复杂性 - 装饰器与组件接口必须一致,限制了灵活性 -- 调试困难(多层装饰时不易识别) +- 调试困难(多层装饰时不易识别) -装饰器模式在Java标准库中有广泛应用,特别是I/O流处理部分(如BufferedInputStream装饰FileInputStream)。理解这种模式有助于编写更灵活、更易扩展的代码。 +装饰器模式在Java标准库中有广泛应用,特别是I/O流处理部分(如BufferedInputStream装饰FileInputStream)。理解这种模式有助于编写更灵活、更易扩展的代码。 #### tips `App\Service\Test\Decorator\ContainerService`