Closed webdevilopers closed 8 years ago
One thing is sure for me: interface FooRepository
.
As for the implementations, it doesn't matter that much, as long it's obvious what it represents.
In most cases I have ArrayFooRepository
or InMemoryFooRepository
. Or I don't, and use mocks in tests.
For production use, I create DoctrineFooRepository
.
In a legacy project I also have MysqliFooRepository
.
As for ORMFooRepository
– there are many ORMs – the name would not tell me much about implementation, so I would avoid it.
As for DoctrineOrmFooRepository
and DoctrineOdmFooRepository
– if I had both, I would name them like that. But I usually have one, so I just do DoctrineFooRepository
. And it's ORM. I never had to rename it, as I never migrated from Orm to Odm. If I did, I'd just rename stuff – should be easy in this case.
But, if I did a library (not a full app), there would be a bigger chance of multiple implementations for the start or in the future – so I might differentiate them from the beginning.
I think that naming them DoctrineORMFooRepository
or DoctrineODMBarRepository
it's a pretty simple and good solution. I like to tend to naming them according the technology they use.
Good compromise! Though Doctrine is the ORM and Mysql or Mongo feels more like a "technology". ;)
That's a way to see it. Doctrine can be treated as another technology as well. :)
Using a folder for Namespacing could be a good compromise.
Platform\Orm\Doctrine\FooRepository
Platform\Odm\MongoDb\FooRepository
I like the idea by @yvoyer of using platforms. Reminds me of the @beberlei Doctrine Extensions structure:
Some examples show InMemory (Redis) and Doctrine (ORM) Repositories. Looking at some Java examples of the red book there are NoSQL examples and they are named after the "DB" e.g. "MongoFooRepository".
Since Doctrine is just the "Mapper" I think repositories should be named similar to the red book examples. Naming them ORM and ODM Mapper could be a possible solution but regarding MongoDB and CouchDN, SQL and MySQL etc. I think it would be better to name them as follows:
I'm currently working and projects blending ORM and ODM via Doctrine and sometimes I have Foo Repository for Mysql AND Mongo. So I had to rename them.
But I guess this is not relevant enough to change half of the book. :) Still would like to hear your thoughts!