dimanche 23 septembre 2018

DRY support for multiple interacting libraries

I've researched many different approaches to abstracting away multiple implementations, but none seem to address the issue of mixing and matching supported implementations.


Consider this scenario:

Subsystem A is implemented using Library A or Library B.

Subsystem B may be implemented using Library C or Library D.

The problem arises from the fact that Subsystem A's implementation may vary slightly depending on the implementation used for Subsystem B.

A concrete example is a windowing API and a graphics API. If SDL is chosen for the windowing API, the setup code varies slightly depending on which graphics API is chosen (OpenGL, Vulkan, DirectX, etc.). This may be true of other windowing as well.

This means that a "one size fits all" windowing wrapper implementation may not necessarily exist.


With the requirement that all supported implementations must be contained in a single binary, how could this be accomplished? Is there a clean pattern that achieves this while keeping code duplication to a minimum? I'd like to avoid making an entire special implementation for every foreseeable combination of libraries.

Aucun commentaire:

Enregistrer un commentaire