Strategy VS Decorator, Elaboration required

Moderatoren: pmueller, SE - Design and Construction

Benutzeravatar
AizazZaidee
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 106
Registriert: 20. Apr 2016 22:49

Strategy VS Decorator, Elaboration required

Beitrag von AizazZaidee » 28. Jun 2018 13:11

Hi,
It is mentioned in the slides.
Unlike Strategy, variations encapsulated in decorator
objects do not leave any footprint in the behavior of the
objects being adapted
How does strategy leaves a footprint? they are chosen on the runtime, for example a Map application so the navigation can be "Walk", "Car", "Bicycle" but each and every strategy is different and Map does not know about which one of them is chosen at the runtime.

So what does it means?

Thanks.

pmueller
Moderator
Moderator
Beiträge: 87
Registriert: 25. Jan 2018 11:14

Re: Strategy VS Decorator, Elaboration required

Beitrag von pmueller » 28. Jun 2018 15:31

Hi,

you can see an example for this in slide 7 of the Strategy lecture,
The layout manager is a field of Container. This obviously leaves a footprint, although the manager can be changed at runtime.
The Container uses the interface of the Strategy directly.
On the other Hand, if you are using a decorator, the wrapped object is not modified in any way directly, and it is now "aware" of the fact that it is decorated.



Best,
Patrick

Antworten

Zurück zu „Software Engineering - Design and Construction“