Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CASE statements
Message
From
23/10/2003 16:57:14
 
 
To
23/10/2003 10:58:22
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00838740
Message ID:
00841834
Views:
24
>SNIP
>>Imagine the above had 20 or 30 steps. I would rather see if the above way than have 30 if statements.
>>
>>You may call it a corruption, I call it an elegant and readable solution to a common coding pattern.
>
>Like I've been saying, it **is** a personal thing...

Absolutly!

>
>But I highly dispute the "readability" of such a CASE. Sure, it *is* more readable in FORM (than a bunch of IFs or some other construct) but it really

AH HA!

>is not 'readable' in terms of quickly determining what is going on when one is searching for a bug or places to revise code.

Why? Actually, if I wanted to, I could have a failure code variable or error message that populates in each case. This would tell me exactally what the point of failure is.

>A CASE is designed to have one and only one conditional of a series have the code under it be executed.

That is exactally what I am using it for. I am looking for a method/expression to evaluate to a false. If it does, it will stop evaluting my expressions. If none evaluate to false than the Otherwise will set my success indicator to true.

>When I encounter a CASE in any code that is my firm expectation - to see a condition in the CASE and some code under it. When I see a series of CASEs with no code under them my first assumption is that the programmer has put them there for 'clarity', to tell the next reader that the condition(s) tested is a known one WHERE NOTHING IS NEEDED TO BE DONE.

Once again, this is what I am doing. If my method call returns ! .f. then I want nothing else to be done! As I said, I could set an error code or message in this 'case' but I choose not to in the sample I put up.

>next one and the next one, etc). This is definitely NOT "readability"! Prettier, yes... helpful - NOT!!!

If you see this construct then you should recognize it for what it is.

>cheers

As you say, we each have our opinion and are neither of us likley to change the other's. However, either way I don't see it as using the CASE statement 'wrong' just an implementation that you don't prefer.

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform