Abstracting database manipulation and other stuff….

I’m currently working on a medium-to-large website for the agency i’m currently working, and i stumble upon a very interesting situation.

Apparently, i will have to code this site without knowing yet which database engine we are going to use. So now my only option to avoid affecting my job is to do implement a Factory pattern on the data structures i will have to use.

So i will create a RepositoryFactory object which will return repositorie’s interfaces, which in turn will return concrete data objects.

This way i think it will be the best option, so now i will be able to create a FakeRepository and create the data object by hand, so when the engine war ends, all i will have to do is to implement the final database engine chosen.

I write this because this is the first time i have to implement a design pattern by a real need, i generaly do it but because i try to code the best i can, but this time, the pattern MUST be used. And what a cool solution!

So the final product should look something like:  RepoRacotry::getXXXRepo()->getSomeData() 

A repo who will return repositories interfaces… and initially, i will implement fake concrete repositories. The data objects will be plain php objects ( no methods or anything, just vars )

–Also: I’m starting to use the Symfony Components by picking and implementing just the ones i like, and it’s a very fun process. Symfony2 is a very cool framework.