There seem to be two kinds of definitions of what a record could be:
1. A full representation of a resource,e.g. (defrecord User [id name age
gender address])
2. A *handle* to a resource, e.g. (defrecord User [id]), e.g. [wikipedia]
below
Some protocols only ever need a handle, not the full resource, e.g.:
(retrieve-from-datomic (->User 42)
But other protocols need a complete representation, e.g.:
(produce-edn-for-api (->User 42 "John Doe" 64 ...)
Is there an idiomatic approach to solving this problem? It seems like the
options are:
A. Define complete representations (#1 above) everywhere, and only
partially fill them in when used as handles (e.g. (->User 42 nil nil nil
nil). This seems somewhat annoying and worse, makes it unclear what
exactly is the data expected as I/O for a given function, which was
original point of making a named, well-defined data structure.
B. Define two separate but related records (e.g. UserHandle vs. User).
This is also somewhat annoyingly duplicative, especially since every
protocol implemented by UserHandle will need to be re-implemented by User
(though it could be a simple delegation thereto).
Is there a standard and/or satisfying way to solve this? Thanks.
- Elliot
[wikipedia] http://en.wikipedia.org/wiki/Handle_%28computing%29
--
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.