Re: Comparing string input to enum data type
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 28 Feb 2007 12:41:14 -0800
"dtschoepe@xxxxxxxxx" <dtschoepe@xxxxxxxxx> writes:
On Feb 28, 10:21 am, rober...@xxxxxxxxxxxxxxxxxx (Walter Roberson)[snip]
wrote:
#define COLORS red, blue, green, yellow, black, purple, pink
It isn't clear why you chose to #define those. Any change in them
needs to be reflected in the routine, so decoupling the symbols from
the routine does not buy you anything obvious.
I used #define so I would have less places to edit in case I added a
color, since I use it in at least 2 places.
You only use the COLORS macro in one place in the code you showed us,
and I can't think of a good reason to use it more than once. You do,
however, have string literals "red", "blue", etc., which would have to
be individually updated if you changed the type.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- Comparing string input to enum data type
- From: dtschoepe@xxxxxxxxx
- Re: Comparing string input to enum data type
- From: Yevgen Muntyan
- Re: Comparing string input to enum data type
- From: CBFalconer
- Re: Comparing string input to enum data type
- From: dtschoepe@xxxxxxxxx
- Re: Comparing string input to enum data type
- From: Walter Roberson
- Re: Comparing string input to enum data type
- From: dtschoepe@xxxxxxxxx
- Comparing string input to enum data type
- Prev by Date: Re: syntactically comprehensive test program
- Next by Date: Re: allocating mem in a function and assigning a ptr to the first byte of that mem array...
- Previous by thread: Re: Comparing string input to enum data type
- Next by thread: Re: Comparing string input to enum data type
- Index(es):
Relevant Pages
|