Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hate Nested IFs? Consider this...
Message
From
12/01/2006 21:43:30
 
 
To
12/01/2006 21:06:08
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01086217
Message ID:
01086419
Views:
24
SNIP
>
>This is what YAG does regularly in COM Codebook, and I tend to disagree with JimN on this one. This is, IMO, an elegant use of the fall-through property of the DoCase construct. It has to perform all the logical tests to reach the success clause, and the first failure precludes the execution of other tests.
>
>To me, this looks like the standard checklist approach:
>
lCanDrive=.f.
>do case
>   case not this.HaveCar()
>   case not this.HaveLicense()
>   case not this.drunk()
>   case not this.tired()
>   case not this.car.tank.empty()
>   ...
>   otherwise
>   lCanDrive=.t.
>endcase
>
>So, if someone doesn't have a car or a license, we don't care whether he has had a drink or two, and we surely won't check the tank in a car he doesn't have.
>
>I don't see anything wrong with this approach, on the condition that the method names are meaningful.

This isn't too bad, but the conditions aren't doing any work either.
But when the construct is used as a mini-mainline but they look like condition tests because all CASEs are assumed to be condition tests they sure mislead me, because I expect CASEs to test things and I expect only 1 CASE to be relevant (or the OTHERWISE).
I can talk/write crap English and still be understood, but it is not recommended for a variety of reasons. Same goes for programming, and just because you can do something doesn't mean you should.
Of course others will disagree. I'm not telling anyone what they should do, only why I don't like it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform