vendredi 25 mars 2022

Best way to propergate a data structure from a chain of project dependencies

I have a Controller project which calls a Provider project, and the Provider project calls 3rd party library:

Controller --> Provider --> 3rd Party

The controller want to get a data structure (let's say CustomInfo) from the 3rd Party.The CustomInfo has various data fields: enum, String, int, etc. There are two ways to do this I am aware of:

  1. Import the 3rd Party library to the Controller project. Thus, the Controller project knows the CustomInfo data structure. But this way seems bad because of adding another coupling of the Controller with the 3rd Party library.
  2. Copy and Paste the CustomInfoclass definition from 3rd Party to Provider project. Then the Controller will only need to depend on the Provider project. But seems copy/paste class definition is a bad behavior too.

So which method is better? Or is there a 3rd method to solve this problem?

Aucun commentaire:

Enregistrer un commentaire