2009 Decorator

2009 Decorator - Decorator Pattern The Decorator pattern...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2009 ACS-3913 Ron McFadyen 1 Decorator Pattern The Decorator pattern allows us to enclose an object inside another object. The enclosing object is called a decorator. The other object is the component, it is the decorated object. The decorator conforms to the interface of the enclosed component and so its presence is transparent to the components clients. The decorator forwards requests to the component, but may perform some processing before/after doing so.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Fall 2009 ACS-3913 Ron McFadyen 2 Decorator Pattern e.g. In a windowing environment, scrolling bars, borders, etc. could be decorators on top of the text view of a document. :textView :scrollBar :border component component draw() draw() draw() When it’s necessary for the document to appear (to draw itself), the draw message would be sent to :border and then: :border would draw itself; :border would send the draw message to :scrollBar which would draw itself; :scrollBar would send the draw message to :textView .
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

2009 Decorator - Decorator Pattern The Decorator pattern...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online