Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why define constants
Message
 
 
À
24/10/2006 21:16:56
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01164235
Message ID:
01164515
Vues:
13
Hi, John.

>Don, if the constant is used in only one place, there is no real advantage to using a constant if its value is something obvious like "my constant". But you'll understand why it might be better to use DAYS_UNTIL_EXPIRY in code rather than GOMONTH(subsview.dsub_start,12*subsview.isub_duration)-DATE().
>
>Also, the app may be subject to a standardized practice that sees all constant values #DEFINEd at the top of each proc, in which case you'd need to respect that standard.

Actually, what you describe there shouldn't be a constant (note that it must be evaluated based on other values and the dayly-changing Date() function). In this case, you should provide a method called DaysUntilExpiration() or similar. I'd probably put this method on the class representing the expiring document, like Policy.DaysUntilExpiration(), or event better -if there are more than one "expiring" documents, in an abstract class at a higher level, like:

AbstractDocument.DaysUntilExpiration()

Regards,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform