What are the disadvantages of using component ? https://youtu.be/13cmHf_kt-Q?t=2429 https://youtu.be/13cmHf_kt-Q?t=218 Clojure namespaces are not instantiable, but they define the dependencies in terms of code that the ns requires in order to function, (and thanks to cljkondo, if it's unused will be hinted) I think with a system map we loose the connection to this clojure source code functionality, and passing a map that is the construction of all dependencies of a system, we can no longer look at the ns declaration and infer the dependencies anymore. Can you share your opinion about using an indirection mechanism to pass dependencies around ?
sounds like you want to try https://github.com/tolitius/mount to understand why using namespaces and vars as basis of systems is a bad idea ;-)
the only true issue with Component (after using it for ~10 years) is that declaring dependencies is disconnected from the code that uses them - e.g. your ring handler expects a database connection to be provided, but you forgot to specify it in the dependency list and you get an NPE
Even mount I think is too magical.
yes, I tried it briefly and it reminded me of my early attempts of writing Clojure as if it was Ruby, global mutable state everywhere and things materializing out of nowhere
The objection to mount and plain def is the global var argument. One cannot run two instances of the same system on the same jvm process. That is not practical. If the norm is to configure a system via env (from twelve factor app) you are not going to run two systems anyway. Have you ?
yes, I frequently would run dev system serving local requests while running tests which use a test version of the system
do you use tools.namespace to reload your code in dev mode ? how that interferes with the running test system. I think it wipes the namespace and crashes the test system, right ?
yes, it's something that does happen but it's recoverable - although admittedly understanding how to work with tools.namespace and make it part of my workflow took a while
> Declaring dependencies is disconnected from the code that uses them
>
When you create a component, if you declare your own constructor fn next to the defrecord, you can create the component wrapped in a call to component/using and then everything lives together. You no longer need to add those deps with component/system-using wherever you assemble the system.
This only works assuming the system key is identical to the key in the component. Or the mapping between the two is well known and not arbitrary.