X Tutup
Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 984 Bytes

File metadata and controls

26 lines (20 loc) · 984 Bytes
layout pattern
title Decorator
folder decorator
permalink /patterns/decorator/
categories Structural
tags
Java
Gang Of Four

Intent: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

alt text

Applicability: Use Decorator

  • to add responsibilities to individual objects dynamically and transparently, that is, without affecting other objects
  • for responsibilities that can be withdrawn
  • when extension by subclassing is impractical. Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination. Or a class definition may be hidden or otherwise unavailable for subclassing

Credits

X Tutup