there are plenty protocols vs multimethods comparisions, but why not to use higher order functions? Let's come with example: We have some data (record for example). And we have methods serialize and deserialize. Say that we want to save it into file, into json, and into database. Should we create protocol called SerializationMethod and records called database, json, file that implement them? It looks kind of hack to create records only to use protocol. Second solution - multimethod - could take string parameter with serialization output and decide how to do this. But I am not sure that is right way to go... And third way is to write function serialize and then pass there data and serializing function. But now I can not name serializing and deserializing method with same name (json fo example):
(defn serialize [method data]
(method data))
(defn json[data]
(...))
The question is how can I (or how should I) do this. Is there more generic way with higher order function? Or maybe I don't understand something well? That are my first steps with clojure so please be tolerant.