I’m looking to write an application. Think e-commerce. But think, an e-commerce site that is powered by another provider.
The scenario would be thus: I would white-label an e-commerce site front that’s powered by a client’s existing e-commerce platform, whether this be Magento, CubeCart, Prestashop, or so on.
These platforms are all going to have their own naming conventions and whatnot, and I want a common interface within my app. For example:
class Product {
var $title;
var $price;
var $image;
var $description;
// and so on
}
Obviously different providers may call things differently. For example, title may be product_title in a provider, or product_name, or productTitle, and so on. Another example: price may be cost, or unit_price, and so on. Hopefully the problem becomes apparent.
Ideally, I’d like to be pointed to the best design pattern to abstract a service from my app’s business classes, so I can add providers without having to re-factor anything in my app down the line.
What design pattern would be the best for the above scenario?
I’d go with something like this:
Depending on the providers you want to integrate with, you may want to add additional Decorators or Facades (for example to simplify API) between Adapters and actual providers.