1 Star 0 Fork 0

stone264/java-design-patterns

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
layouttitlefolderpermalinkcategoriestags
patternExtension objectsextension-objects/patterns/extension-objects/Behavioral
JavaDifficulty-Intermediate

Intent

Anticipate that an object’s interface needs to be extended in the future. Additional interfaces are defined by extension objects.

Extension_objects

Applicability

Use the Extension Objects pattern when:

  • you need to support the addition of new or unforeseen interfaces to existing classes and you don't want to impact clients that don't need this new interface. Extension Objects lets you keep related operations together by defining them in a separate class
  • a class representing a key abstraction plays different roles for different clients. The number of roles the class can play should be open-ended. There is a need to preserve the key abstraction itself. For example, a customer object is still a customer object even if different subsystems view it differently.
  • a class should be extensible with new behavior without subclassing from it.

Real world examples

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuqr32/java-design-patterns.git
git@gitee.com:wuqr32/java-design-patterns.git
wuqr32
java-design-patterns
java-design-patterns
master

搜索帮助