Stratergy Pattern just an Interface?

Watching this video all I am taking away is that the Strategy Pattern is just using an interface. Is this correct or am I missing something?

No.

You can use an Interface to help implement a strategy pattern, but an Interface in itself is not a strategy pattern.

1 Like

While you can use an interface in a Strategy pattern, you can also use any sort of base class… For example in the Shops and Abilities course, we use a base class derived from a ScriptableObject for each of the various strategies bases… What’s important is that the Strategy Pattern takes advantage of Liskov’s Substitution Principle. From the perspective of the script that is calling the Strategy pattern, any strategy that is employed can be substituted for any other strategy with the same methods being available to the script. As far as the script is concerned, there is no difference between the acceptable strategies.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms