My goal would be (working in Prestashop) obtain data from distinct webservices, representing several entities data and handle this data (validation, dependencies checks and persisting) having in mind that there're different behaviors for each entity.
Details: The context is Prestashop, in this case, I have to obtain entities data (categories, products, stocks) from a webservices datasource. And each class must have in it's behaviour their capabilities to validate, mapping, check and persist that info to Prestashop models.
I'm trying to do that work with my possible best design, so i've been researching for some design patterns and studyng the problem but it seems like it does not fit in my head.
I've notice that maybe a combination of repository pattern to get some abstraction from datasource to model, factory pattern for letting each class to implement it's behaviors (category must handle it's dependency checks different than products, for example) would do the job, but i cannot fit it together.
I've looking at examples like ' http://ift.tt/1p37PT9 ' which look like a good path but I don't see exactly how to adapt to my needs.
A posibility is: Every entity would implement, let's say "synchronizable", which would be composed by pieces like "validator", "persister" etc... To handle this several components and classes, i'd need to use a factory pattern to easily instantiate the correct class (avoiding these endless "ifs") but i'm afraid that these classes (let's say "ProductSynchronzable") would end with too much funcionality (even it's functionality is derived from different components).
As you can see, firstly my english is not so good, sorry about that. Secondly my head is a mess.
I'd only need a little guidance to focus this problem the right way.
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire