On 25 March 2011 10:41, msappler <msapp...@web.de> wrote: > Never used metadata until now. > > I had an insight yesterday that I want to share with you: > > http://resatori.com/metadata-insight
In my view, it depends whether your :id key is a surrogate key or a natural key. Object metadata should not affect object equality, so if your :id key is just an internal database identifier, you could include it as metadata. But if your :id key is exposed to the outside world, then it should not be metadata, because changing the :id would change the external representation of the object, and therefore affect equality. I should also point out that if you want information hiding, then object composition might be a better solution. For example: (defprotocol Identifiable (id [self] "Return an object's unique id")) (deftype DBRef [db-id data] Identifiable (id [_] db-id) clojure.lang.IDeref (deref [_] data)) (defn db-ref [id data] (DBRef. id data)) Then we can get information about the reference, and deref it to get its contents: (def user (db-ref 193 {:login "fred"})) => (id user) 193 => @user {:login fred} - James -- 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