Christian Eitner <7enderh...@gmail.com> writes:

>>
>> Hi Christian,
>> I think you are looking for this.
>>
>> http://en.wikipedia.org/wiki/Facade_pattern
>>
>> In clojure you can use a def for each private member of the facade. 
>> Alternatively you can write a function to instantiate and return private 
>> members. Use a defn for each facade's methods.
>>
>>
> I'm not sure in how the facade pattern would help me on the conceptual 
> level.
>
> I'm pretty confident that I can work out the technical details of how to 
> get my fingers at the existing objects or how to interface from the OO 
> world into Clojure code.
>
> The question is more like, how should I model the integration?
>
> It seems pretty useless and/or dangerous to me to put the mutable objects 
> into Clojure's immutable data structures and work on the them directly. 
> Would I kind of extract the objects' data (value-like) into my data 
> structures, perform operations an these and in the end retransform those 
> values onto the objects?


I've been through this with by Tawny-OWL library
https://github.com/phillord/tawny-owl. I wanted clojure for the flexible
syntax and evaluative environment, but I am driving an stateful, event
driven API (namely the OWL API http://owlapi.sourceforge.net/).

In the end, I have basically ignored a lot of what people feel makes
clojure nice. Most of my functions have side-effects, I use state. I
even make use of Stuart Sierra's top clojure anti-pattern. I just use
Clojure to drive the event-driven framework underneath. 

The practical upshot of it is that some of clojure's clever features,
like the concurrency support are relatively useless, and some of them
(lazy sequences) are nothing other than a pain in the ass.

I still, found Clojure to be a good choice. Lazy sequences are
irritating, but not a major disaster, just requiring typing doall a lot.

And I think my approach was still the right one. For instance, I can use
Clojure to drive a Java application that is built with the OWL API just
by sharing the underlying data structures with Tawny
(http://vimeo.com/79136990). Doing this if there was two sets of data
structures that I was keeping in sync would not be good. And all was
relatively easy to achieve because of the Clojure ecosystem -- nrepl,
cider, maven (dependencies) and pomegranate. I've just been very careful
NOT to replicate in the Clojure what the API will do for me; I most
don't store mutable objects Clojure data structures (for any length of
time), and on the odd occasion that I do, I do not depend on their
state.

I have been toying with turning the mutable objects into Clojure data
structures; originally, to support a form of user documentation, but I
am toying with idea of querying and searching over them. I think this is
going to work, but it's going to be slow. For my use case, I don't think
the slow performance will be a disaster.

Phil



-- 
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.

Reply via email to