473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 "RegisterVehicle" 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 1600

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

Similar topics

13
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...
27
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...
9
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
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...
3
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...
37
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. ...
10
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.