← BYTES
Design Patterns·Starter·Ref: 17.1.18
What is a key benefit the Strategy pattern provides when a program needs to choose between several interchangeable algorithms at runtime?
Have a question about this video? Mention reference 17.1.18 when you contact us.
a.It lets the algorithm to use be selected and swapped at runtime by injecting a different Strategy object implementing a shared interface, without changing the client code that uses it
b.It hardcodes exactly one algorithm with no way to ever change it
c.It requires rewriting the client code every time a different algorithm is needed
d.It only works with exactly two possible algorithms, never more
Strategy encapsulates each interchangeable algorithm behind a common interface, letting client code depend only on that interface -- a different concrete Strategy implementation can be substituted (even at runtime) without touching the client code that uses it, directly enabling runtime algorithm selection.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES17118#DesignPatterns