3 ms·
This is alluded to in Price #2: No Packaging. I’d argue that grouping functions into namespaces largely resolves this problem. These two slides in the Clojure
by filoeleven 6y ago
This is alluded to in Price #2: No Packaging. I’d argue that grouping functions into namespaces largely resolves this problem.
These two slides in the Clojure, Made Simple talk are my favorite counterpoint to even shallow objects being easier to work with than data. See starting at 50:00:
https://youtu.be/VSdnJDO-xdg https://youtu.be/VSdnJDO-xdg
If you don’t want to click through, the list of HttpServletRequest methods is bigger than the map itself! Each one is its own little DSL, and they are not consistent with each other. To do anything with the data, you first have to figure out which method gets the bit you want out of the thing. And that’s a simple case—the complexity only goes up from there.
The map OTOH is just a map; you have hundreds of simple, composable functions that you can use to slice and dice the data however you need.
Want the keys? (keys request)
Want the keys of the headers? (keys (:headers request))
The user-agent value? (get-in request [:headers “user-agent”])
None of these are specific to a servlet request; they will work on any piece of data. And it’s trivial and transparent to build more specific functions out of them that fit your problem domain.