• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
alnite

What's the proper name for this class?

15 posts in this topic

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?

0

Share this post


Link to post
Share on other sites

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.

Edited by alnite
0

Share this post


Link to post
Share on other sites

Smells pretty anti SRP to me...

 

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

1

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Finding the verbs in your system and creating classes for them is the classic procedure-oriented antipattern.  Not that there's a lot wrong with procedure-oriented design, unless what you're trying for is object-oriented design so you can take advantage of many of its long-term benefits.  Using classes and object for procedure-oriented design will bring you and the people who have to maintain your code grief.

 

In good OO design, you look for the nouns (object) in your system and create classes for them, then look for the verbs that act on the nouns and create functions for them.  If you're using your noun in the subjective case, you probably have a member function, and if it's in the objective case, you probably pass it as a function argument.  Not a hard-and-fast rule.

 

Using an agent noun ("eg. a 'manager' is something that performs the action denoted by the verb 'to manage') in place of the verb itself for a class name is still procedure-oriented programming.  Classes are nouns, functions are verbs.

 

My guess is that the original requirement was to be able to insert, remove, or update rows in a table in a relational database, or maybe (key, value) pairs in a persistent lookup table (what the folk who learned all their computer science off marketing whitepapers call a nosql database).  I image there are various additional verbs for those nouns for performing metaoperations (like connecting to the RDBMS, fetching a row, committing a transaction).

 

Just remember: nouns are classes, verbs are functions.

0

Share this post


Link to post
Share on other sites

I'd personally go with something like DBModifier or maybe even DBController if it was my project. 

0

Share this post


Link to post
Share on other sites

I usually find this sort of class that encapsulates all SQL operations called a DAO; they cover the whole spectrum from dumb and generic (often simple CRUD operations, with the extreme of supporting query builders that write WHERE clauses on the fly) to complex and specialized (e.g. methods executing multiple or different SQL statements depending on data). The common trait is avoiding, or at least abstracting and minimizing, "business" logic that goes beyond accessing data and treating SQL errors.

 

Typical naming patterns refer to the database tables, under the assumption that different tables have different purposes and DAO changes follow table chages.  For example a DAO that operates on the Widget table only can be called "WidgetDAO", while one that combines access to the Widget, Gadget and Screw tables (either because they are considered a logical grouping or because they are actually used together) could be called "MechanicalWorkshopDAO".

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0