Pretty tiring, boring, unnecessary fancy words for js world.
const strategyA = {
run : function () {}
}
...
const strategies = {
strategyA,
strategyB,
...
}
// below string should be a variable to make it more dynamic.
// And can be wrapped with try/catch if not exist will throw error
strategies['strategyA'].run()
I'm PhD. in Computer Science from Málaga, Spain. Currently, I am teaching developers and degree/master computer science how to be experts in web technologies and computer science.
As a former academic, in another field, this article reminded me of when I couldn't explain something to a 12-year-old. I'm new to design-patterns, and have avoided them, but form what I understand, batuxd, the strategy-pattern is simply when one should encapsulate (or store and make accessible for later use) what varies.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Pretty tiring, boring, unnecessary fancy words for js world.
Thanks! 🙃
As a former academic, in another field, this article reminded me of when I couldn't explain something to a 12-year-old. I'm new to design-patterns, and have avoided them, but form what I understand, batuxd, the strategy-pattern is simply when one should encapsulate (or store and make accessible for later use) what varies.