Sunday, March 05, 2006
Functional Design Patterns
A few days ago Grady Booch blogged that he had catalogued close to 900 design patterns. Whilst this is a monumental achievement it strikes that there me that there is something fundamentally wrong with this - there are too many patterns to be practically useful. Choosing a pattern will not be a science based on a handful of principals, but an art driven by aesthetic considerations (and there is nothing intrinsically wrong with that). As you might be aware, over the past few months I've been scratching my formalist itch again and looking at functional programming languages and lambda functions. I've been trying to understand monads, but as yet I don't have a good feel for them - I haven't done a comprehensive search, but I've not found many accessible papers on how to design or use monads. One of the better papers is The Design of a Pretty-printing Library by John Hughes. Roughly, monads correspond to higher order lambdas. So whilst it is well known that many design patterns are simple applications of functional programming (e.g. visitor == map), I can't help but ponder how many of Grady Booch's 900 design patterns are simple applications of higher order functions in functional programming. There doesn't appear to be a lot of work done in this area... any pointers/references would be great to know. Update (16/3): I've just reread (parts of) Monads for Functional Programming, and the ideas in it are beginning to gel.