Common scenario: I have a library that uses other libraries. For example, a math library (let's call it foo) that uses numpy.
Functions of foo can either:
- return a numpy object (either pure or an inherited reimplementation)
- return a list
- return a foo-implemented object that behaves like numpy (performing delegation)
The three solutions can be also restated as:
- foo passes through the internally used object, clearly stating that its library dependency is also a API dependency (since it returns objects obeying the interface of the numpy library)
- foo makes use of a common subset of objects that are part of the basis of the language.
- foo completely hides what it uses internally. Nothing about the underlying libraries escapes from the foo library to the client code.
We are of course in a pros-cons scenario. Transparent or opaque? strong coupling with the underlying tools or not? I know the drill but I am in the process of having to do this choice, and I want to share opinions before taking a decision. Suggestions, ideas, personal experience are greatly appreciated.