持久层的命名约定:DAO vs Manager vs ...?

Rom*_*man 7 java oop naming naming-conventions

免责声明:我几乎可以肯定我以前见过同样的问题但我现在找不到它.如果有人发现了这个问题,请给出一个链接.

我听到至少有两个关于实现CRUD操作的类的最佳名称的意见:有人说这DAO是一个经典名称,每个人都知道这意味着什么,但是其他人说这Manager对CRUD功能更好.

我应该何时选择一个或另一个(或另一个)名称,是否有任何明确的规则?

Jac*_*son 6

I definitely don't like Manager; "managing" something could mean (and is used to mean) all kinds of things. If you're afraid people won't know what DAO means, you could always spell it out as "DataAccess", say. But I find DAO to be widely understood.

Another approach is to use the Repository pattern and call your class SuchAndSuchRepository. This isn't necessarily the same thing as a DAO (it may wrap one or more DAOs) but it can provide a clearly named place to go to get your objects -- if I want a Person object, I know to look for the PersonRepository.