4 ms·
Here's my take: 0 customers asked for it: Don't abstract it. 1 customer asked for it: Corner-case it. 2 customers asked for it: Strategy pattern. 3 customer
by snorkel 16y ago
Here's my take:
0 customers asked for it: Don't abstract it.
1 customer asked for it: Corner-case it.
2 customers asked for it: Strategy pattern.
3 customers asked for variations: Config option.
- KirinDave 16y agoThis is not a bad plan, but there is a danger here. If you find that "1 customer" (being a series of disparate customers) all ask for various minor tweaks to the way something works, then before you have half-a-dozen disparate forks in your logic you probably do want to pull that out and use a strategy pattern where applicable. It doesn't take many clever sidesteps in a clean algorithm to make a nightmarish scenario later on.
- jacquesm 16y agoI'd roll 1 and 2 together, typically if one customer asks for it today another one will ask for it next week. Save yourself the time and bother to dig back in again and solve it at least for the foreseeable future with less overhead than what it would take to tackle the same task again, typically getting in to do the job takes at least as long as doing the job in situations like that (just to make sure you didn't break anything by accident, test the works and so on). If the overhead is constant and a 'small' fix like that takes 5 instead of 4 hours including all the extras then that's a trade-off worth making. Unless of course you're really under pressure.
- KaeseEs 16y agoSomething I've wondered for a while: how does the strategy pattern differ from just passing a function pointer?
- Deestan 16y ago> how does the strategy pattern differ from just passing a function pointer? It's just a verbose way to perform the same abstraction. Use it only if function pointers are unavailable or considered unsafe in your programming language.
- Raphael_Amiard 16y agoThere are a bunch of patterns that simply disappear, or are greatly simplified when you have first class functions in your language, namely, observer, strategy, visitor, and a bunch of others i can't remember right now