Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25435
| From | Sebastian <news@seyweiler.dyndns.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: OO Design Patterns vs FP |
| Date | 2013-10-02 21:31 +0200 |
| Organization | albasani.net |
| Message-ID | <l2hs8j$mg2$1@news.albasani.net> (permalink) |
| References | <l2gi7f$3gc$1@news.albasani.net> <l2he49$rka$1@dont-email.me> <l2hh3u$be$1@news.albasani.net> <l2hl8f$7p4$1@dont-email.me> |
Am 02.10.2013 19:31, schrieb Jeff Higgins: > On 10/02/2013 12:21 PM, Sebastian wrote: >> Am 02.10.2013 17:29, schrieb Jeff Higgins: >>> On 10/02/2013 03:33 AM, Sebastian wrote: >>>> Hello there, >>>> >>>> has anyone written about the relation of OO design patterns (by which I >>>> mean the usual GoF patterns) to functional programming idioms? >>>> >>> >>> relation+of+OO+design+patterns+to+functional+programming+idioms >>> <http://bit.ly/15ILqCW> >> >> I did Google a bit before posting, you know. One finds a couple of more >> or less incoherent discussions on blog posts, then one finds very >> theoretically-minded stuff that's sort of _inside_ FP. > > The subject has been widely bantered about. > Here's one discussion begun in 2008: > <http://stackoverflow.com/questions/327955/does-functional-programming-replace-gof-design-patterns?rq=1> > > Here's a useful quote from Neal Ford's article series on IBM developerworks: <quote> 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.) </quote> 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. -- Sebastian
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OO Design Patterns vs FP Sebastian <news@seyweiler.dyndns.org> - 2013-10-02 09:33 +0200
Re: OO Design Patterns vs FP Jeff Higgins <jeff@invalid.invalid> - 2013-10-02 11:29 -0400
Re: OO Design Patterns vs FP Sebastian <news@seyweiler.dyndns.org> - 2013-10-02 18:21 +0200
Re: OO Design Patterns vs FP Jeff Higgins <jeff@invalid.invalid> - 2013-10-02 13:31 -0400
Re: OO Design Patterns vs FP Jeff Higgins <jeff@invalid.invalid> - 2013-10-02 15:16 -0400
Re: OO Design Patterns vs FP Sebastian <news@seyweiler.dyndns.org> - 2013-10-02 21:31 +0200
Re: OO Design Patterns vs FP Jeff Higgins <jeff@invalid.invalid> - 2013-10-02 15:55 -0400
csiph-web