Fork me on GitHub
#polylith
<
2021-10-06
>
cjmurphy01:10:43

There's a book that's pretty old now: 1995. Designing Object-Oriented C++ Applications Using the Booch Method. Prentice Hall.https://en.wikipedia.org/wiki/ISBN_(identifier)<tel:9780132038379|978-0132038379>. Has anyone read it? It comes up with a metric for how 'good' your software is, based on dependency relationships. Basically it is good to have domain/utils components such that all the dependency arrows point to them, and they don't point to other components. The interesting thing is this metric could be calculated for a Polylith application. If you've heard of 'afferent' and 'efferent' coupling then that's what this is about.

cjmurphy06:10:00

And the other good type of component to have is one that really uses (points to) other components, but is not used by them (think main). Bad components use and are used in equal measure. A reasonably good metric means your software is maintainable.

seancorfield02:10:56

https://www.entrofi.net/coupling-metrics-afferent-and-efferent-coupling (for folks who have not read the book). Yes, looks like Polylith could calculate those -- and the instability metric, and even the stable dependencies principle. Or a new tool could, based on the ws.edn data.

oly13:10:37

what do you do in your interface when you have a multimethod that can take zero or more args ?

oly13:10:41

Should i be doing soemthing like this ?

(defn get-gcp-token
  ([] (c/get-gcp-token))
  ([args] (c/get-gcp-token args)))

tengstrand15:10:00

I would say you have two main options. One is to do it the way you suggest. The other option is to do it something like this (if you have a default value):

(defn get-gcp-token
  ([] (c/get-gcp-token "my-default"))
  ([args] (c/get-gcp-token args)))
If the “my-default” value is something that changes over time, I would go with your approach, because then it should be an implementation detail, but if it is something hard coded (more or less) then the second alternative is a bit simpler, because you only need one implementing function.

oly16:10:17

ah yeah good point I did not think of moving the multi method to the interface, for a lot of my usages that would likely work as its usually for defaults when not provided cheers

👍 1
seancorfield03:10:11

Or perhaps:

(defn get-gcp-token
  [& args] (apply c/get-gcp-token args))
Although I'd want {:arglists ..} metadata there to provide more useful hints in the editor/REPL.