Alex Miller's recent blog post on this is quite relevant http://insideclojure.org/2015/04/27/poly-perf/ On Fri, 15 May 2015 at 12:00 pm Max Countryman <[email protected]> wrote:
> I personally prefer multimethods, generally speaking—I think they feel > more idiomatic. Although it does depend on the context of what you’re > doing. In some cases a protocol may be the correct choice. Here the > multimethod seems fine. > > > On May 14, 2015, at 16:34, Jason Marmon <[email protected]> wrote: > > I'm working on a tool to orchestrate the migration from mongodb to > datomic, and i'm looking for a bit of design feedback as i'm new to > clojure. > > > The user needs to provide functions that transform mongodb documents into > datomic txes. Do y'all prefer the top or bottom style, or think there's a > different way to implement this design that might be better? > 12345678910111213141516171819 > > ;; Multimethod for transforming data based on the name of the source mongodb > collection > (defmulti transform identity) > > (defmethod transform "events" [data] > ;; do something with data > ) > > (defmethod transform "users" [data] > ;; do something with data > ) > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > (defprotocol Collection-Transformer > (transform [mongo-db document])) > > (def user-transformer > (reify Collection-Transformer > (transform [m d] "do stuff"))) > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > 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 [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > 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 [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
