Persistence Level Naming Conventions: DAO vs Manager vs ...?

DISCLAIMER: I am pretty sure I saw the same question before, but now I can’t find it. If someone finds this question, please give a link.

I have heard at least two opinions about the best name for classes that implement CRUD operations: someone says that DAO is a classic name and everyone knows what that means, but others say that Manager much better at CRUD functions.

Are there any unambiguous rules when I have to choose one or the other (or another) name?

+6
java oop naming-conventions naming
source share
3 answers

I definitely don't like the Manager; "manager" can mean (and is used to mean) all kinds of things. If you are afraid that people will not know what DAO means, you can always say it as “DataAccess”, say. But I believe that the DAO will be widely understood.

Another approach is to use the Repository template and call the SuchAndSuchRepository class. This is not necessarily the same as a DAO (it can wrap one or more DAOs), but it can provide a clearly specified place to search for your objects - if I want a Person object, I know you're looking for a PersonRepository.

+6
source share

+1 for DAO.
The manager is unclear and can be applied to many things other than the DAO.
e.g. swing.DesktopManager, ErrorManager, FontManager, JavaFileManager, XMLEntityManager are some of the 200+ classes currently available in my workapce IDE, none of which seem to have anything to do with saving the database.

+2
source share

I would say manager, because any "assumptions" can cause some chaos. And in this case, I think that you assume that every authority knows the DAO.

0
source share

All Articles