DEV Community

Discussion on: Help, these objects have the same shape but don't share an interface!

Collapse
 
hilariocunha profile image
Hilário Cunha

My two cents.

The simplest solution is the one said by Alain Van Hout.

But depending on your constraints, probably a refactor of the code to use a business object is better.
You would be independent of the format used to save the data, meaning that you could in the future change your third-party library, if needed.

Tip:

  • If you don't have the source code of the third-party library you can try to use ILSpy to get the code and use that as base to create your business object.
  • And for the mapping BO <-> DTO, Automapper can help you there.