haps
haps copied to clipboard
Possibility to use multiple bases
Suppose the following case:
- I'm getting a
ClientFoofrom an external library "Ext".ClientFoois very complex and it is difficult to do composition over inheritance, and I don't want to extract an interface either as the third-party package might change in the future, causing unnecessary maintenance effort. - I want to write my own shared library "Shared" and
@injectClientFoofrom "Ext" in some type initializers, so I annotate it with@baseand@egg. - In the actual application "App" (using both "Ext" and "Shared"), I want to amend
ClientFoowith some custom functionality, so I create a subclassClientBar. It would be valid to injectClientFoointo types of "Shared", but not necessarily into all the types of "App" because of the extra features required. In "Shared", I would like to rely only onClientFooso that its types become reusable but still easy to instantiate, whereas I want to receive concreteClientBarsin "App".
To solve this, my first thought was to annotate ClientBar with both @base and @egg aswell, but that violates the "single base" principle.
Is it possible to overcome this issue with the constraints given above? Alternatively, is there a simple way to monkeypatch haps to allow using multiple bases in particular cases?