What's the proper name for this class?

Started by
14 comments, last by LorenzoGatti 11 years, 2 months ago

I'm writing a class that inserts/updates or deletes records to a database table. I can't come up with the proper name for this class.

DBInsertor? Sounds pretty stupid.

DBRecord? It's ambigous as it doesn't represent any DB record or model.

DBRecordKeeper? It doesn't keep or store records.

Any ideas?

Advertisement

DBMutator?

Can you post an example of how you would use that class?

RecordDBProxy? :P

o3o

I would have a text file with the values to be stored to the database. For example:

first_name: "John"

last_name: "Smith"

Then it reads this text file, parses the column names, checks if the column names actually exists in the database, then stores them. It creates a new entry if the values do not exist. It updates the entry if it already existed. It can also delete an entry based on a certain criteria, for example, by first_name.

So I would use it like this:

// Initialize db bla, bla bla

db_whatever.insert("datafile");

db_whatever.update("datafile");

db_whatever.delete("first_name", "John");

I was thinking DBRecord sounds the closest, but it doesn't represent the data. It inserts data into database.

edit: It may also extract data from database.

Smells pretty anti SRP to me...

anyway, from the methods shown, DBContext, DBConnection, or just Database?

Smells pretty anti SRP to me...

Single responsibility principle? I would say it is, at method-level, rather than class-level :D

anyway, from the methods shown, DBContext, DBConnection, or just Database?

DBContext and DBConnection doesn't sound bad. I was looking at C# documentation, and came across: TableAdapter or DataAdapter, which might be a good candidate too.

DBRecordInserterUpdaterAndOrDeleter

or possibly

DBRecordThingDoer

or just

DBSecretary
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

DBRecordInserterUpdaterAndOrDeleter

I vote for this. Clear and to-the-point.

But honestly, if you're set on that set of functionality (file i/o AND database query), then you'll want a fairly non-standard name to denote that it carries a non-standard role.

I would have suggested something like DBBasicConnection because of it's similarity with a standard idea of a Connection UNTIL you mentioned that insert() and update() functions take filenames, that kind of throws standard out the window.

If you take this from a top down manner:

It relates to databases which suggests to me a "database" or "db" namespace instead of trying to work that descriptive bit into the name directly.

It does three things which suggests this is a management class or a supervisor or some controller type class which is top level to decide what functionality to perform.

I tend to use 4 variations of description based on ownership level:

1) The "manager", owns the item in question and can perform the suggested operations directly.

2) The "controller", doesn't own the item but tells other systems what is to be done.

3) The "supervisor", which is simply a decision engine around the item in question. (This is a subtle difference from controller.)

4) The "processor", which is used to run through many items and add tags, make lists, whatever for other things to deal with.

So, given the original question, I would start by using a namespace to wrap the concept instead of trying to put it in the class name. The language was not specified but the names suggest a C/C++ background so that's what I'll assume.

namespace db/database { class Record[xxx] }

Insert proper descriptive item into "xxx". I'm not much of a person for coding standards but I do like logically organized naming conventions. Hopefully my description of the way I name things might help.

Why not break it up a little? Have a DBParser, DBEntry and a DBController(or something similar).

This topic is closed to new replies.

Advertisement