Hacker News new | past | comments | ask | show | jobs | submit login

You can slap "command pattern" on anything. But I'm speaking directly in the traditional form that implies a OO type hierarchy.

You don't need that at all.

Here is a "proof" of sorts: http://mishadoff.com/blog/clojure-design-patterns/#episode-1...




Yup. Command pattern is short for "my language doesn't have first-class closures".


I'm aware.

But either it makes sense to use Command Pattern or not in any given situation and it has nothing to do with complexity really.

I don't see how someone could possibly use a command pattern when simple function would do - that would be beyond pointless. Which makes me believe that there must have been something to the nature of the problem question ...

(Though Lambda's wipe out so many of the simpler use cases of command pattern ...)


The whole point was that the GoF Command Pattern is a verbose OO emulation of simply passing around functions. In a language with proper first-class closures the whole pattern mostly dissolves – it’s obvious that if you want to customize behavior, just pass a function. The same holds for a surprising number of GoF patterns.


i think even if you use lambda's - i would still call it a command pattern - if you used lambdas to implement the command class.


It's an issue of perspective at this point. You can call it "The Command Pattern", as if it was something Important, while others will note that it's just passing a closure around (i.e. a trivial programming pattern at the level of "using if/else" or "throwing an exception").




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: