Which design pattern is best allowed for one class from multiple providers?

I am looking to write an application. Think about e-commerce. But think about an e-commerce site that runs from another provider.

So the scenario: I would call an e-commerce site based on a client platform for e-commerce, whether it be Magento, CubeCart, Prestashop or so on.

All of these platforms have their own naming conventions and much more, and I want to use a common interface in my application. For instance:

class Product {
    var $title;
    var $price;
    var $image;
    var $description;
    // and so on
}

Obviously, different providers may call things differently. For example, it titlemay be product_titlewith the supplier or product_nameor productTitleetc. Another example: pricemaybe costor unit_priceetc. I hope the problem becomes apparent.

Ideally, I would like to point out the best design template to distract the service from my application business classes, so I can add providers without rearranging anything in my application.

What design pattern would be best for the above scenario?

+5
source share
3 answers

I would say something like this:

enter image description here

, , Decorators (, API) .

+4

, Facade -. , API, API.

+2

, . . ( "" ) .

0

All Articles