What would be the best way to implement the following behaviour: I have an interface represented by a function ans = my_interface(args)
, I have several implementations of this function and I want to give the user permission to select one of the implementations by setting a parameter.
The obvious solution would be to make each implementation a function with identical interfaces and in my_interface
process the parameter and depending on its value call one of them. If I want to extend, I need to add a new function with a new implementation of the engine and change my_interface
to process a new engine's name. And I have to be aware of the proper interface here. I don't think it is the smartest way.
I would also apreciate a link on the book or discussion of this matter. I have found a similar functionality in Keras for example, where it can use either Tensorflow or PyTorch backends. Does anyone know how it is implemented?
Aucun commentaire:
Enregistrer un commentaire