Browse thread
[Caml-list] OCaml and Design Patterns
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | pad@r... |
| Subject: | Re: [Caml-list] OCaml and Design Patterns |
Brian Hurt <bhurt@spnz.org> writes: > On Wed, 20 Oct 2004, David Brown wrote: > > > On Wed, Oct 20, 2004 at 06:30:01PM +0100, Richard Jones wrote: > > > > > Just my personal opinion, but I've seen a lot of terrible code written > > > which uses "design patterns" ... A lot of the patterns seem to exist > > > solely to bypass problems with OO languages. > > > > Design Patterns seem very similar to what is usually called idioms in other > > languages. They're just common constructs you learn for common tasks. An > > example in ocaml might be typical recursion for a loop. > > > > However, the OO Design Patterns do seem more to be techniques used to > > compensate for defects in the OO methodology, or specific languages. > > > > I would suspect that when someone encounters a place to use a design > > pattern in OCaml, the problem would much better be solved by using some > > other feature of the language. > > > > I don't seem to have quite as negative a view of the GoF book as many > people around here seem to. But I think this is because I see design > patterns as a more general idea than just what the GoF presented- and I'd > argue this view is supported by the pattern community- as now you have > software architecture patterns, anti-patterns, etc. I think there are OO > patterns (which is what is documented in the GoF book), functional > patterns, even procedural patterns. I totally agree with you. In fact the haskell community have developped design patterns at: http://www.haskell.org/hawiki/CommonHaskellIdioms They have adapted the idea of GoF to push it further cos in functionnal langage the main ideas of the GoF book were already known/used by the fp community. > > I also think that the difference between idioms and patterns is mainly a > matter of degree- they're all of a kind, if you see. > > Note that there are a number of Functional patterns which are for working > around the limitations of the Ocaml language as well. An example I'll > hold up here is "build a list backwards, then reverse it" pattern, to make > a function tail recursive. Others are less clear cut- is "return the > update applicative structure" a work-around, or a better way of doing > things? > > The point I'd like to make to the original poster is that the GoF isn't > the last word on how to think about problems, especially not in Ocaml. > Look for the new patterns Ocaml allows/encourages. People generally disrespect the work done by other communities (and then reinvent it giving it another name). ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners