by, sanjay krishna anbalagan decorator pattern (structural)

7
By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

Upload: abraham-hugh-horton

Post on 20-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

KeyPoints Interface(implements) – abstract class(extends) Inheritance Concrete class Wrapper Number class wraps string variable Now variable S has number characteristics. It acts like a number

TRANSCRIPT

Page 1: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

By,Sanjay Krishna Anbalagan

Decorator Pattern(Structural)

Page 2: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

IntroductionDecorator Design pattern – adds features to core

objects without having to fundamentally change those objects.

Christmas tree - core object (component class)Ornaments – features(decorator class)

Page 3: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

KeyPointsInterface(implements) – abstract class(extends)InheritanceConcrete classWrapper

Number class wraps string variable

Now variable S has number characteristics.It acts like a number

Page 4: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

Component

Operation()

Concrete Component

Operation()

Decorator

Operation()

Concrete Decorator - A

Operation()

Concrete Decorator - B

Operation()

Algorithm

•Instantiate a concrete component

•Wrap the Instantiated concrete component in the desired decorator instance.

•Apply the getterMethod to the concrete component instance initiated to get the fully wrapped values

Page 5: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

ACmodel

getDressed()

CCdoll

constructor

ADdresser

getDressed()

CDpinkdress

getDressesd()constructor

CDcap

constructorgetDressed()

CDyellowdress

getDressesd()constructor

v

v

v

v

v

Page 6: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

Points to RememberThe developer has to be judicous in selctionAre the concrete components and

decorators going to grow?Are they going to be fairly static?

Page 7: By, Sanjay Krishna Anbalagan Decorator Pattern (Structural)

ReferencesActionScript 3.0 Design Patterns William Sanders & Chandima

CumaranatungeAdvanced ActionScript 3 with Design

Patterns Joey Lott & Danny Patterson