>From my experience, protocols are essentially contracts between
various modules of the code base - the fewer they are (in number) the
better my peace of mind! IMHO if you just need to pass around function
implementations, consider using defrecord.

(defrecord OrderProcessingView [fn1 fn2 fn3...])

(defn make-opview [{:keys [f1 f2 f3]
                    :or {f1 some-fn1 ; default implementation for f1
                         f2 #(...) ; default implementation for f2
                         f3 (fn [x] (foo x)) ; default impl for f3
                         }}]
  (OrderProcessingView. f1 f2 f3))

Having a factory function (e.g. make-opview) helps get more done by
writing less; de-structuring helps even further. Maybe if you can
share some code examples it would be easier to comment.

Regards,
Shantanu

On Oct 15, 6:58 pm, "K." <kotot...@gmail.com> wrote:
> Hello,
>
> I'm a developping a Swing GUI in Clojure and follow the MVC patterns.
> The view implements a protocol for displaying data, and another one to
> register Swing listeners. Callbacks registered with the second
> protocol only access the UI through the view protocol.
>
> Each of this protocol has ~50 functions (and it's growing every
> day...).
>
> Even if I do some delegation when implementing these protocols, the
> deftype implementation has already ~700 lines.
>
> Is there a way to split the definition in several files or namespaces,
> or more generally, what would be the best way to organize this
> architecture?
>
> I don't think subdivising the view in several views makes sense, since
> from the point of view of the listeners it's really only one entity
> (but maybe I'm wrong on this).
>
> Thanks in advance for your suggestions.

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

Reply via email to