From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA20465; Wed, 20 Oct 2004 21:22:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA20515 for ; Wed, 20 Oct 2004 21:22:27 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9KJMPVm017457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 20 Oct 2004 21:22:26 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.13.1/8.12.11) with ESMTP id i9KJMG1l005336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 20 Oct 2004 14:22:18 -0500 (CDT) Date: Wed, 20 Oct 2004 14:31:11 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: David Brown cc: Richard Jones , Subject: Re: [Caml-list] OCaml and Design Patterns In-Reply-To: <20041020184714.GA25862@old.davidb.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 4176BAF1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 terrible:01 idioms:01 recursion:01 idioms:01 applicative:01 work-around:01 ocaml:01 ocaml:01 supported:01 procedural:02 constructs:02 wrote:03 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 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. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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