In the usual Strategy Pattern, we make each strategy as a class. Can't we make it a function, and just assign the reference to the function when we instantiate an object, and let the object call that function?
Depends on the language. In C#, you could make it a delegate. In Java, it would rather be a anonymous class. In C++, you could really make it a function pointer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With