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:07, Dru Sellers <d...@drusellers.com> wrote: > 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 OO > ideas into the functional nature of Clojure. I'm looking for any help > someone can provide to help shimmy my brain into the right mental patterns. > > Background: Long time C# developer who leans heavily on IoC / DI / > Interfaces / Testing / Object Encapsulation. > > > *Specific Question: Object Encapsulation* > I feel like my function parameter lists are much "wider" than they would > be in C#. This is due to the "lack" of a constructor. So if I previously > had a C# class that looked like: > > > public class AccountRepository : IAccountRepository > { > IDatabaseConnection _connection; > > public AccountRepository(IDatabaseConnection connection) > { > _connection = connection; > } > > public void Save(Account account) > { > _connection.Execute("UPDATE accounts SET coupon=@coupon WHERE id=@id", > { coupon = account.Coupon, id=account.Id}); > } > } > > In the above I have encapsulated the "_connection", the other methods > don't have to deal with it. In Clojure (especially if you are following > Sierra's Component pattern) you end up with > > (defn save [db account] > (update db (:coupon account) (:id account)) > ) > > I end up having to pass this 'db' around all over the place. I think that > this is just something I'll have to get used to more than anything. Am I > missing anything? > > Thank you for your time. > > -d > > -- > 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 group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.