by fuball63 · 7y ago · 0 comments
I work primarily in Python, and one thing I see all the time is using dictionaries instead of method arguments. The thought is that when the method evolves over time, you can just add a field to the dictionary. What ends up happening is this dictionary argument is passed up and down the call stack for every nested method call, and sometimes elements are added, edited, or deleted on the way.
Whenever I have to do a refactor of methods like this, it is awful trying to figure out the state of the dictionary, what was originally supposed to be in it, and if it's returned, which parts are actually relevant.
(defn foo [{:keys [bar baz]}]
;; do something...
)
(foo {:bar 1 :baz 2})
This isn't as good as a type signature, but makes it easy to know what the dependencies to a function are.