samedi 4 avril 2020

How to add behavior to a big class hierarchy we can't want to modify

I have a component who is a connector between two products. He is called by SoftwareA, and the API is defined in software A, and he talks to SoftwareB who owns his API too. So this component is in the middle of those to APIs, without his own model. We can't change SoftwareA nor SoftwareB.

So the connector is called by software A, call SoftwareB and map the response from the Api A to the Api B. The connector does not have his own model. We want to change that so we can add some behavior, add some fields to simplify some business logic.

The API of both softwares is huge.

For example (simplified of course) : A is the root, extended by B, who is extended By C our main object. A has a D, B has a list of E, C has list of F (and so on).

As a starting point we want to add some behavior in F because we have identified a way to simplify our business logic if we can customize this object (keeping some values of the API B that are not mapped).

For now we think that it is too expensive to create a new model for the connector. We would have to modify all mappers, and that's a big effort. We wanted to improve the model as things progress. We are going to use a wrapping approach. We started to create a wrapper to the C object because this object is our main object, and then create other wrappers where we need, in our case a wrapper for F.

What do you think about this approach. Is there other possibilities ?

Regards

Aucun commentaire:

Enregistrer un commentaire