Mar 29, 2019
0
Level 3
Multiple implementations to an external api - best approach. (contracts, interfaces, something else?)
My scenario is as follows:
- I am writing a system that can book shipments with various shipping companies.
- There will a number of different couriers and "booking" will be via an external API with differing methods.
- Fundamentally the inputs (package size, type weight) and outputs (shipment label, tracking number) should be the same, even though the way I get them will differ.
Is this a good scenario for contacts and interfaces? I usually see these used as a way to change system wide implementations (i.e. from file to database drivers) and am not sure if they are so suitable when switching between different concrete classes on the fly.
I want a way to ensure that I can add new shipping companies easily, without having to change any of the code that interacts with the various API's.
Please or to participate in this conversation.