I'm looking at custom constants again and have put together some thoughts. I wanted to post them here for the sake of the archives, and to solicit expansions, corrections, tips and the like. If you've got anything to add, please contribute!
Here goes: * Right now, not that many people are using thread-safe processes in V16, but that will change. One of the limits of preemptive mode is that you cannot use IP variables. For a lot of existing 4D systems, IP variables have been used instead of custom constants. So, going forward, making custom constants easier to love is a Very Good Thing. * Custom constants are great, but they can be a bit of a pain...so they aren't used as universally as they could be. (Should be?) * One of the pains is that you have to reopen the database to see custom constant modifications. *This makes sense.* Constants are values that cannot change at runtime, so 4D loads them once at startup before our code. *But this is a pain.* If you agree, please vote in favor of this feature request: Please add a 'Reload constants' command http://forums.4d.fr/Post/EN/19514761/1/19514762 * 4D supports custom constants of the simple types Longint, Real, and String. * Boolean would be a big help, please vote in favor of this idea here: Please add support for custom constants of type Boolean http://forums.4d.fr/Post/EN/19514786/1/19514787 * Constants are better than static variables because no lookup, initialization, etc. needs to be done. The value is set once and that's it. In a compiled application, the value of the constant is baked right into the code. So, you can throw away a constants file from a deployed component or application. * Duplicate constants are a Very Bad Thing. With that in mind: -- Remove constants from compiled components. Helpful. -- Consider a naming starting constants like K_ or your initials, a module prefix, or a program-specific prefix. * 4D Pop works fine, but then the constants definition is not in your code. Alternatively, Jim Dorrance has posted some constants management code here and Cannon Smith includes custom constants code in some of his (free) modules. I'm using Cannon's code at the moment and it has made my life a *lot* better. No criticism of 4D Pop (none! I'm grateful), but I find it easier (a lot easier) to have everything in the code. * Sigh. Constant names/labels are limited to 31 characters. Why? No idea. If you agree that this limit is too low, please vote in favor of this request: Raise the 31 character name limit on methods http://forums.4d.fr/Post/EN/18946884/1/18946885 It's on 4 stars with 56 votes. Four more and it hits 60 votes! P.S. If you don't think 31 characters is too low a limit for names, you are a monster. Just saying. What have I missed? Been misleading about? Been wrong about? Please post tips, corrections, suggestions, etc. ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

