473,668 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enums or Key/Value Pairs?

We are trying to develop a set of C# 2.0 web services that are data driven,
loosely coupled, easy to maintain, and somewhat high preferment (I'm sure
that's either an oxymoron or everyone else's dream too?!?) Anyway, we need to
be able to take an "arbitrary" number of key (or name) /value pairs that do
have a finite, but changeable, set of possible values to them. What is the
best (practice) approach to accomplishing this without compromising (too
badly) any 1 of the 4 qualities that we are looking for?

For example, let’s say we have a webmethod called "RegisterVehicl e" that
takes a "Vehicle" as the input. The Vehicle can be of type "Car", "Truck", or
"Motorcycle ". If it's a "Car", then we would need to know "How many doors",
"Make", "Model", "How many cylinders the engine has", and the "Type of fuel".
For a "Truck" we would have the same, but maybe add "4 Wheel Drive or not"
and "Bed length". For "Motorcycle " we wouldn't need "Number of doors". And so
on and so forth.

So as you can see, some of the inputs are somewhat set (Car, Truck, or
Motorcycle), but the others could change at any time and are mostly dependant
on the type of Vehicle that you are submitting.

If we create enums and expose those through the WSDL, we would need to
recompile and redeploy our services, plus existing client may need to do the
same. However the validation is "free", but we would probably also have to
maintain enums in C# code as well as "enums" in the database.

If we take an "array" of key/value pairs with some min/max bounding
constraint, it make the validation of those key/value pairs a bit more error
prone (i.e. just doing string comparisons, room for type-o's, etc.), but is
much more flexible in what can be passed in by any given client application.

Anyone dealing with this type of thing now?
Aug 3 '07 #1
0 1622

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

Similar topics

13
9545
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could change and lead to memory corruption. I didn't see how this was possible. He claims that if a dll built for a program is built with different compiler settings than the launcher program, the enum size could change. The only way I could figure...
27
2726
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template <typename Enum> class smart_enum { public: typedef Enum enum_type;
9
1762
by: Jarmo Muukka | last post by:
Hello all! I have used C++ for many years and recently I have used C#. Now I am coding in C++ and I have a problem now. In C# you can do enums like this: enum Lane { Left,
4
5588
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and when looking at the db we can't tell what the value in a field represents. The other problem is that our enums are currently all stored in a single class, which means that because of no visibility constraints the enums are often used out of context...
3
7592
by: Jeff L. | last post by:
I have an interesting problem and I'm not coming up with any answers in my searches, so hopefully someone can give me a hand with this. I have a feeling it's easy, but I usually get my nose stuck too far in the details to see the big picture. :) I want to create a collection of key/value pairs. I have a class for the key/value pair...we'll just call it KeyValuePair for this example. Now, when creating the collection, I need to be...
37
2206
by: mdh | last post by:
In one of the answers to a K&R exercise, the first couple of lines are: enum loop { NO, YES}; enum loop okloop=YES; I get the first line, but not the second. Sorry about the LOL question. Thanks in advance
10
3841
by: Jay | last post by:
In C# I can set up an Enum so that number are represented as keywords, which is very useful. Is there such a datatype in a database? I suppose I could use an extra table, with the ID column as the number, and a corresponding column with strings representing the keywords. This sounds a bit inefficient - is there a better way?
4
2993
by: Jon Slaughter | last post by:
is there a simple way to "step" through enums? I have a button that I want to click and have it "cycle" through a set of states defined by enums but the only way I can think of doing this "properly" yet "ugly" is to test the state for each state. I know that enumes are not ordered but since they are "stored" as numbers they have an inherent ordering which can be used. I don't really care about the ordering though but just the ability to...
0
8462
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
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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
8656
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
7401
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
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
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...
1
2791
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
2023
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.