473,657 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best methodology for a common db/front end issue

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?
Feb 2 '07 #1
3 1431
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.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"PokerMan" wrote:
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?
Feb 2 '07 #2
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.
"Ciaran O''Donnell" <Ci************ @discussions.mi crosoft.comwrot e in
message news:34******** *************** ***********@mic rosoft.com...
>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.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"PokerMan" wrote:
>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?

Feb 2 '07 #3
On Fri, 2 Feb 2007 15:08:27 -0000, "PokerMan" <no****@pokerca t.co.ukwrote:
>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
Feb 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
2784
by: Richard James | last post by:
Are we looking at the scripting world through Python colored glasses? Has Python development been sleeping while the world of scripting languages has passed us Pythonista's by? On Saturday Slashdot ran this article on the "best" scripting languages. http://developers.slashdot.org/developers/04/06/12/2125229.shtml?tid=126&tid=156 "Folks at the Scriptometer conducted a practical survey of which scripting language is the best. While...
131
21631
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately get some good real world examples. Fire away! :) Regards, Peter Foti
16
3018
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
3
1712
by: Johan Nilsson | last post by:
I've seen many alternatives when it comes to referring to types defined in parent/sibling/other namespaces. Consider the following hypothetical namespace layout: namespace company { namespace lib { class SomeClass {};
22
1799
by: Ally | last post by:
Could someone give me an example of a modern development methodology? Just to see if I'm thinking along the right lines... P.S. Sorry for the cross posting but I couldn't find a newsgroup for systems analysis.
5
3189
by: wrecker | last post by:
Hi all, I have a few common methods that I need to use at different points in my web application. I'm wondering where the best place would be to put these? I think that I have three options. 1. I can create a common module like common.vb in my project and put all the functions in there. 2. Create a utility class and create the common functions as shared
4
1378
by: mharness | last post by:
Hello All, I've defined a number of classes that currently only include public variable declarations. I've been reluctant to add subroutines and functions for fear of taking a performance hit when I pass the class as an argument to another function and in a one case, store the class to a session variable. Right now I have all of my functions and subroutines in a single class that's becoming a bit unwieldy. What I'd like to do is move...
6
1900
by: Wayne Shu | last post by:
hi everyone! I have a problem in implementing a common class interface. my assignment is to implement a data structure list, and I have define a class template list_base, it's an abstract class, only define the common interface of all various list. The definition is below: template <typename T> class list_base { public:
19
10742
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is there an existing adapter? Thanks, Daniel.
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.