Best methodology for a common db/front end issue

  • Thread starter Thread starter PokerMan
  • Start date Start date
P

PokerMan

Hi

A common situation is a database using an ID number for a table and the
front end code needing to read this same id and store it back when used in
foregin key tables.

For example:

database table

RoomType
-------------
RoomTypeId
RoomType

and assume values

RoomType
--------------
1 | DoubleBed
2 | SingleBed
3 | Penthouse


etc

What i do is read that into my code and make an enum like:

enum RoomType{
DoubleBed,
SingleBed,
Penthouse
}


Is there a better way than this? My concern is what if the ids of the
roomtype table were ever changed? My code assumes they will never change and
so i just put my front end in sync with the ids. Am i using the right or an
acceptable methodology here?
 
I you intend to be able to administer the list of roomtypes then you need to
use objects rather than enum entries. If you dont ever want to be able to
change the list without doing a software build/test/release cycle, then this
is acceptable.
 
I presume you mean use an object as in, load in the roomtypes from the db,
store in an object or struct and then use those vars throught my app yes?

And no i dont expect the variables to ever be changed, but you never expect
something to not happen until it happens. I am just making sure i am ready
and aware of a worst case scenario here really.
 
I presume you mean use an object as in, load in the roomtypes from the db,
store in an object or struct and then use those vars throught my app yes?

And no i dont expect the variables to ever be changed, but you never expect
something to not happen until it happens. I am just making sure i am ready
and aware of a worst case scenario here really.

Howdy PokerMan,

When developing software for businesses or even individuals for that matter,
never, never, never say, "It will never change.". If you write durable code you
may find the room type changing when the new owner buys the hotel and implements
HIS/HER business logic.

Good luck with your project,

Otis Mukinfus

http://www.otismukinfus.com
http://www.arltex.com
http://www.tomchilders.com
http://www.n5ge.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top