Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming conventions for persistence layer: DAO vs Manager vs ...?

DISCLAIMER: I'm almost sure that I've seen the same question before but I can't find it now. If someone finds that question, please, give a link.

I heard at least two opinions on the best name for classes which implements CRUD operations: someone says that DAO is a classical name and everyone knows what it means, but others say that Manager corresponds much better to CRUD functionality.

Are there any unambiguous rules when should I choose one or another (or yet another) name?

like image 600
Roman Avatar asked Jun 24 '10 13:06

Roman


1 Answers

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.

like image 171
Jacob Mattison Avatar answered Sep 28 '22 00:09

Jacob Mattison