Keith Bennett
unread,Feb 1, 2009, 6:00:54 PM2/1/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure Study Group Washington DC
David -
Interesting idea. It would seem to me that a functional language like
Clojure would make implementing the Strategy pattern simpler than in
other languages like Java since it is so easy to pass functions
around.
In a way, I guess one could also argue that functional languages have
been heavily using the Strategy pattern since before it was named,
since so often a function is being passed to operate on a sequence/
list. And, while the Strategy pattern refers to accomplishing a given
task in different ways (and not different tasks in different ways),
I'm sure that this was done pretty often over the years in functional
languages.
I like the idea of explicitly designing the app using the Strategy
pattern because I think it will result in more cohesive (and therefore
cleaner) code. I'd like to look at the code again, though -- it might
already be doing that, and I just didn't notice.
I posted my previous message about a fork allocation strategy before
absorbing your message, but I guess that's exactly what I was offering
-- an alternate strategy for the initial fork allocation, like you
say. Optimal strategy depends on the objective, though -- I was
seeking to optimize clarity, and, as I understand it, Michael was
illustrating an interesting mathematical implementation for
educational purposes.
I guess in order to support multiple strategies, we'd have to define
the parameters and return value for all implementations of a given
strategy. That might be a good first step. This might require
revisiting the data design. All in all, I think it would be a great
exercise. We might wind up with exactly the same program Michael
showed us, but we'd understand it a lot better. ;)
- Keith