-
Notifications
You must be signed in to change notification settings - Fork 39
Loose coupling
A system is loosely coupled when its components have little knowledge of the internals of other components.
Components A is loosely coupled with component B if A communicates with B without concrete knowledge about the internals of B.
Web services that communicate via JSON are loosely coupled.
In Clojure, inside a program we "just use maps" to communicate. This is based on the principle that "we should program the insides of our systems like we program the outsides". Outside, we have loose coupling everywhere: over the wire we communicate via data (e.g. JSON). Let's do the same inside and communicate via data (e.g. hash maps).
Compare that with functions that receive a record (or a data class) as an argument. In order to call those functions, we need to import the definition of the record. That's not loose coupling!