I'm trying to understand the programming philosophy expressed in some of 
the videos, as it relates to dealing with data with different 
representations. There's a lot of emphasis on working with basic collection 
types,  not using getters and setters, and so-forth.

I have a fairly common scenario where I have a set of operations that need 
to work on two types of data (not "data types" in the clojure sense) that 
have different internal structure (i.e. maps with different keys). I could 
write a generic function that operates on both types of map. That would 
require implementing getters for each type (not sure where those would 
live). Alternatively, I could use a type-based dispatch, which means 
converting to records. Does that mean I'm in my "defrecord phase", as 
Stuart put it in the video? Or perhaps I could stick with maps and use a 
multimethod for dispatch? But dispatch by type and dispatch with 
multimethod both involve implementing all the algorithms twice, unless the 
methods I'm dispatching to are just getters (in which case I can write a 
generic algorithm that uses the getters).

I don't think I understand the alternative to getters or the "defrecord 
phase". Have I missed something by arriving at this point in the first 
place (i.e. thinking I need polymorphic functions)?

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