Lee Warner
Lee Warner

Reputation: 2593

Is there a common name in use for an object that gets data from a database?

I'm developing an API for use by one of our vendors to access data in our databases and I need to name my classes. I'm thinking about names such as Retriever, Accessor, and Controller (eg. TimesRetriever, TimesAccessor, TimesController, etc). These classes will provide read only access to data (that I'll be summarizing) in our database. Is there a commonly agreed upon naming convention for what I've described?

Upvotes: 2

Views: 2284

Answers (5)

SergioL
SergioL

Reputation: 4963

Martin Fowler (www.martinfowler.com) is a good source for these types of question; since, you're really talking about design patterns.

My best guess would be the Repository pattern (http://martinfowler.com/eaaCatalog/repository.html).

From the site:

Conceptually, a Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer.

Sounds like what you are trying to do.

Upvotes: 3

Scott Saunders
Scott Saunders

Reputation: 30414

"Controller" is used to mean something different. "Accessor" is often used for DB access classes. For this sort of thing, I generally think of it as a Report. In other words, you're not giving full access to to the DB, you're just showing a Report from it based on certain selections (I assume). So, if the output format allows (especially if it's CSV), I would rephrase the whole project as an API to run reports. If that's not possible, I'd go with "Accessor".

Upvotes: 0

Sake
Sake

Reputation: 4143

It's called "Adapter" in LLBLGen Pro

It's called Provider in Delphi DataSnap And Java SDO

I don't think there is a commonly agreed naming convention.

I tend to use Provider or Retriever.

Upvotes: 0

Jeff Peck
Jeff Peck

Reputation: 21

I've most commonly seen people use a "Manager" suffix. I've also seen people use Database as suggested by just_wes. Ex: TimesManager or TimesDatabase or even just Database.

Upvotes: 0

just_wes
just_wes

Reputation: 1318

A simple suggestion... why not call it "Database"? That is as clear as you can get. When reading that, you'll know where all the data is coming from right away.

Upvotes: 1

Related Questions