Strategy design pattern
submitted 3 years ago by DevTalker from (ddimitrov.dev)
[–]zyxzevn 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 0 fun2 insightful - 1 fun - 3 years ago (0 children)
I often notice that the strategy pattern breaks.
I can explain it via the Algorithm() example: It works for sort variants, it is a relatively pure function with input and output. But many algorithms and optimizations are not so isolated. They need more than just a function-call.
For example with path-finding You can have a hidden state, like a cache. Or do work in front by scanning the terrain to build a network. A network of paths that contain optimized paths from one area to another. So if you in one area, you only have to pick the paths from the graph. This front-work may be very costly, and would rather be done up-front, before any path-finding is done. But if the terrain changes, you may need a new set of optimized paths. Or when all paths are blocked, you need special code that starts opening that path.
And these complex examples are more common than the simple sort() function. And they need insight in the whole state-dynamics of the system. Which can change dramatically when new features are added to the program.
use the following search parameters to narrow your results:
e.g. sub:pics site:imgur.com dog
sub:pics site:imgur.com dog
advanced search: by author, sub...
~2 users here now
Links:
[–]zyxzevn 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 0 fun2 insightful - 1 fun - (0 children)