Fork me on GitHub

Is there a recommendation for how to avoid duplicating the interface definition for a component that has multiple implementations (for example, the documentation example has the same interface defined and


The set of functions has to be the same in both components. It follows the same principle as in object orientation that every class that implements a certain interface, has to implement all the methods for that interface. I don't know if that answered your question?


No, sorry - what I mean is, just say I have a (hypothetical) interface with 100 functions, do i need to duplicate the interface.clj across components that implement that particular interface (ie in the example, there is a user-remote and user component, both implement se.example.user.interface). Or is another option to have a user-interface component that only contains the interface definition, and the interface implementation in a separate component (that is selected either through the default profile or an alternate profile). just thinking how to avoid having to define interface.clj in two separate files and keep them in sync.


This is one case of polylith being different to traditional interface polymorphism. Traditionally, source dependencies point from the implementation to the interface, so multiple impls can reference a single interface definition. (java interfaces, clojure protocols etc) Here the interface references the implementation so it's more akin to 2 otherwise unrelated classes defining the same set of public methods with the same signatures.

gratitude-thank-you 1