Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why define constants
Message
 
 
To
25/10/2006 17:28:40
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01164235
Message ID:
01164696
Views:
9
Dan,

It can be a pain finding constants in a .h file, but hopefully they've been named in a manner that actually makes the code easier to understand.

What's more understandable?
if ( Messagebox( "Delete all your data?", MB_YESNO + MB_ICONEXCLAMATION ) = IDYES )
   zap
endif

* or

if ( Messagebox( "Delete all your data?", 52 ) = 6 )
   zap
endif
IMHO single use strings shouldn't be a #define, obtuse numeric values should be.

>Well, this is probably the longest thread that I have ever launched. Thanks to all of you who participated. My original question was formed because of the difficulty (for a beginner at least) to read and understand code where you have to keep chasing other files and code blocks to understand what is going on. I'm again trying to teach some beginners, and providing them with code samples that come with VFP where they have to drill down (or up) several layers to find the code that's actually executing is a royal pain. If we in the VFP community really want to preserve the language, we need to do more to make it easier for a rank beginner (someone with no programming experience.) I am still fighting the VFP vs Access/VB battle constantly in my organization. (sorry for the lecture)
>
>So I conclude from the discussion that there is no real consensus on the issue, and that if the messagebox text (for example) appears in only one place in the program, then it's generally acceptable to use a string literal rather than a defined constant.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform