Re: Question about data structures and encapsulation

2011-06-17 Thread Ken Wesson
On Fri, Jun 17, 2011 at 12:58 AM, Ryan Twitchell metatheo...@gmail.com wrote: Just for reflection: What would you do with an existing class which had a getName() method, when you suddenly realized you wanted getFirstName() and getLastName() instead?  Or the reverse? If you can't refactor the

Re: Question about data structures and encapsulation

2011-06-17 Thread Colin Yates
Interesting points. Thanks for the pragmatic advice. Your statement With that in mind, note that such compositions usually address the problems of structuring a program in some new way, often at run time. Functional programming has lots of its own solutions for such problems sums up my issue -

Re: Question about data structures and encapsulation

2011-06-17 Thread Christian Schuhegger
Thanks a lot for the link to the paper about FRP! My personal thinking is going 90% in the same direction that the paper describes. I am happy to see that somebody else did the hard work of writing it down :) Is anybody aware of an implementation of such an approach for Clojure? -- You received

Re: Question about data structures and encapsulation

2011-06-16 Thread Alessio Stalla
On Jun 16, 2:59 am, Colin Yates colin.ya...@gmail.com wrote: Thanks for all the help, all of you.  The Clojure community has a reputation for being helpful :) The example of age as a property which might change from a value to a function was indeed a strawman, but it was just an example.  So

Re: Question about data structures and encapsulation

2011-06-16 Thread Vincent
nice podcast thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this

Re: Question about data structures and encapsulation

2011-06-16 Thread Mikkel
This could be one way to solve the problem in the example and keep a uniform API: (def joe {:age ((fn [] (- 2011 1979)))}) (:age joe) # 32 Any comments on that? On Jun 15, 8:41 pm, Colin Yates colin.ya...@gmail.com wrote: Newbie so go gentle please :).   I am an experienced OO Java developer

Re: Question about data structures and encapsulation

2011-06-16 Thread Laurent PETIT
2011/6/16 Mikkel mikk...@gmail.com: This could be one way to solve the problem in the example and keep a uniform API: (def joe {:age ((fn [] (- 2011 1979)))}) (:age joe) # 32 Any comments on that? You're applying the function immediately. It's not different than doing (let [age ((fn [] (-

Aw: Re: Question about data structures and encapsulation

2011-06-16 Thread Meikel Brandmeyer
Hi, one could use lazymap: https://bitbucket.org/kotarak/lazymap. Unfortunately, it is broken at the moment. Have to bring up-to-date with 1.2 and later. (defn person [name year-of-birth] (lazy-hash-map :name name :age (- 2011 year-of-birth))) The actual difference would only be calculated

Re: Question about data structures and encapsulation

2011-06-16 Thread Caleb
Colin, I just read this definition from SICP, which made me think about your question again: In general, the underlying idea of data abstraction is to identify for each type of data object a basic set of operations in terms of which all manipulations of data objects of that type will be

Re: Question about data structures and encapsulation

2011-06-16 Thread Ryan Twitchell
Regarding JavaBeans and the like, more often than not I've found that when getters and setters do not reference fields directly, they are contributing to a composition: as an adapter, a facade, or whatever- you-please. It is not quite as often that getters simply return a calculation based on

Re: Question about data structures and encapsulation

2011-06-15 Thread Ken Wesson
On Wed, Jun 15, 2011 at 2:41 PM, Colin Yates colin.ya...@gmail.com wrote: In Clojure, if I understand correctly, the preferred way would be to use a map (or defstruct) with keys such as :name and :age.  These are then retrieved as (person :name) and (person: age) etc. My question is if I

Re: Question about data structures and encapsulation

2011-06-15 Thread Meikel Brandmeyer
Hi, and just today this was posted to reddit: http://skillsmatter.com/podcast/scala/talk-by-patrick-fredriksson Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that

Re: Question about data structures and encapsulation

2011-06-15 Thread Laurent PETIT
Hi, I must admit my thoughts are still not fixed concerning this, guided by several considerations: * consider the ring spec: it specifies what keys are expected to be present in the request map, the response map. Good enough. * Wait ! what if some keys could be calculated from others

Re: Question about data structures and encapsulation

2011-06-15 Thread Sean Corfield
Hi Colin! Welcome to Clojure! On Wed, Jun 15, 2011 at 11:41 AM, Colin Yates colin.ya...@gmail.com wrote: the very common Person class will expose get/setName(), get/setAge() etc. and as a consumer I have no idea how the results are calcualted. The FP approach certainly takes some getting used

Re: Question about data structures and encapsulation

2011-06-15 Thread Colin Yates
Thanks for all the help, all of you. The Clojure community has a reputation for being helpful :) The example of age as a property which might change from a value to a function was indeed a strawman, but it was just an example. So the consensus seems to be that yes, that requirement is hard