com.dp4j
Annotation Type Decorator


@Documented
@Target(value=TYPE)
public @interface Decorator

Intent:

Decorator Pattern Implementation UML Class Diagram

Motivation

Extending an object s functionality can be done statically (at compile time) by using inheritance however it might be necessary to extend an object s functionality dynamically (at runtime) as an object is used.

Consider the typical example of a graphical window. To extend the functionality of the graphical window for example by adding a frame to the window, would require extending the window class to create a FramedWindow class. To create a framed window it is necessary to create an object of the FramedWindow class. However it would be impossible to start with a plain window and to extend its functionality at runtime to become a framed window.

Applicability & Examples

Example - Extending capabilities of a Graphical Window at runtime

In Graphical User Interface toolkits windows behaviors can be added dynamically by using the decorator design pattern.

Decorator Pattern Example UML Class Diagram

See Also:
Decorator



Copyright © 2011. All Rights Reserved.