Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-11 Thread Herwig Hochleitner
Hm, the most common way to encapsulate in clojure is with a closure: Your account repository would be: (defn account-repository [connection] ;; <- here goes additional constructor logic (fn save [account] (sql-save connection account)) If the repository has more methods than just save, y

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-11 Thread Dru Sellers
Thank you everyone for all of the helpful ideas. I def like the Component library and I will have to sit down and figure out how to best work that into my application while it is still young. All of the links have been consumed and I am starting to absorb more and more. Thank you for taking the

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-09 Thread Gregg Williams
@Dru, I feel I'm ahead of you in learning Clojure, but I'm not yet to where @Colin is. However, I'm close enough that I recognize how accurate and concise his advice is--in fact, I'm saving it to remind myself! Also, I just finished reading Functional Programming Patterns in Scala and Clojure,

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-09 Thread Henrik Eneroth
If you find yourself passing the same argument over and over, you can always work in a partial: (def save-account (partial save db)) On Sunday, February 8, 2015 at 6:47:29 PM UTC+1, Colin Yates wrote: > > I missed the salient point about data transformations which is that of > abstractions. In

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-08 Thread Colin Yates
I missed the salient point about data transformations which is that of abstractions. In OO (Java at least) almost everything was a special case, in Clojure it is the polar opposite; almost nothing is a special case. It is astonishing how many domains can be sufficiently modeled as a sequence o

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-08 Thread Colin Yates
+1 This separation of behaviour and state is a key part of Clojure's philosophy. That isn't to say that stateful components are bad as such (Stuart Sierra's https://github.com/stuartsierra/component is an obvious analog here) only that they aren't a given as they are in OO languages. As Jony says,

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-08 Thread Jony Hudson
To put take a different angle on it: you might soon get to *like* that it's usual to pass in everything as a parameter explicitly. It has the advantage that it's easy to reason about what a function does just by looking at the function. In the example above, when reading AccountRepository.Save y

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-07 Thread James Reeves
I think there's less difference than you imagine. In C# you might write: repository.Save(account) Whereas in Clojure: (save repository account) The parameter lists are wider in Clojure only because Clojure doesn't have an explicit method call syntax. - James On 7 February 2015 at 16:0

OO Programmer trying to move to Clojure: Encapsulation

2015-02-07 Thread Dru Sellers
Greetings, I am trying to convert my mind from OO (C#) to one more functionally friendly. I am increasingly comfortable with simple applications in clojure, but as I start to build more complex applications, I start to fall down about how to structure my application. I don't want to just shove