From 6857486f27c356da8c7770c27cc5ea5013bde011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sr=C4=91an=20Paunovi=C4=87?= Date: Thu, 4 May 2017 12:33:25 +0200 Subject: [PATCH] #541 Create README.md file --- extension-objects/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 extension-objects/README.md diff --git a/extension-objects/README.md b/extension-objects/README.md new file mode 100644 index 000000000..e345952ed --- /dev/null +++ b/extension-objects/README.md @@ -0,0 +1,28 @@ +--- +layout: pattern +title: Extension objects +folder: extension-objects +permalink: /patterns/extension-objects/ +categories: Behavioral +tags: + - Java + - Difficulty-Intermediate +--- + +## Intent +Anticipate that an object’s interface needs to be extended in the future. Additional +interfaces are defined by extension objects. + +![alt text](./etc/extension_obj1.png "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 + +* [OpenDoc](https://en.wikipedia.org/wiki/OpenDoc) +* [Object Linking and Embedding](https://en.wikipedia.org/wiki/Object_Linking_and_Embedding)