I am building some middleware between our ERP and a cloud based online store. We have multiple business divisions who will use this cloud based ERP, however each business stores their attributes (such as product related attributes) in different fields in the ERP. Because of this, I can't have a standard method of grabbing the data from the ERP. They may map to the same destination fields but they won't come from the same place.

What is the best way to build this in a way that I can have different configurations for different business divisions?

I'm thinking the best way to approach this might be to have an AbstractProductTransformer that has the common attributes, and then have the business division specific implementations such as Business1ProductTransformer and Business2ProductTransformer that implements IProductTransformer. I would then have a factory method that would return an IProductTransformer.

Is this the best approach?


This would most certainly provide the most flexible option, yes. The AbstractProductTransformer would be a convenient base jumping point for new implementations, but if you only use IProductTransformer, you also permit new implementations to follow less stringent guidelines, for instance if a possible implementation doesn't have a attribute readily available and must query for it.

If you find yourself requiring certain operations to be performed often, don't be afraid to add a method in IProductTransformer and providing a default behavior in AbstractProductTransformer if you have all the base attributes you require in order to do it.

Just don't make the mistake of adding methods or attributes that may be specific to a certain business division and not others. Require all the attributes and/or methods you require in order to make use of IProductTransformer and nothing else. Any implementation-specific details can be left abstract.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.