Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: OO Design Patterns vs FP Date: Wed, 02 Oct 2013 15:55:13 -0400 Organization: A noiseless patient Spider Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 2 Oct 2013 19:54:58 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6b9e92482af47766954d85fb77d372f5"; logging-data="30083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kayPhfTjmCNoZOgrKs3KLmfiroXFz3Dg=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: Cancel-Lock: sha1:YyYSSK3+HZh0QqErAPb+cM0l3mg= Xref: csiph.com comp.lang.java.programmer:25436 On 10/02/2013 03:31 PM, Sebastian wrote: > Here's a useful quote from Neal Ford's article series on IBM > developerworks: > > > In the functional-programming world, traditional design patterns > generally manifest in one of three ways: > 1. The pattern is absorbed by the language. > 2. The pattern solution still exists in the functional paradigm, but the > implementation details differ. > 3. The solution is implemented using capabilities other languages or > paradigms lack. (For example, many solutions that use metaprogramming > are clean and elegant — and they're not possible in Java.) > > > My reading so far could be summarized like this: > > - Strategy > -- take functions (Java 8 lambdas) that implement a strategy > -- provide functions to choose from > > - Template and Factory Method > -- these patterns also relate to supplying concrete behavior > -- abstract template methods may become simple members (lambdas), > concrete subclasses disappear > > - Command > -- disappears, because object wrapper not needed for portable > functionality in Java 8 > > - Chain of Responsibility and Decorator > -- composition of (partial) functions > > - Adaptor > -- adaptor classes can be conveniently replaced by (composable) lambdas > > - Visitor > - more complex, no direct correspondence > - special case for streams: reduce (decouple traversal of stream from > operation on stream elements) > > > I’d welcome any comments, additional examples of correspondences etc. > A bit more useful as a starting point for discussion. Thanks. :)