05-18-2009 04:35 AM
Solved! Go to Solution.
05-18-2009 04:47 AM
I'm not sure what you're asking here, but each constant on the block diagram clearly requires it's memory space for storage. The more constants you have, the more memory is required. It oughn't affect performance, however, unless you're talking about several hundred megabytes of constant data being passed around.
Besides - is there any alternative? When you need a constant, I can't imagine there's a more efficient manner of providing one than to use one?
05-18-2009 05:03 AM
FYI Thoric
See the attched image.
Thanks for your reply.
05-18-2009 05:09 AM
05-18-2009 06:46 AM
From your pic, YES!
It is better to use a single constant by placing it outside of case structure and/or loops (for/while), if the data is going to be the same.
We need to program this way, whether or not the constant is big or small (from memory perspective), just for the sake of easy understanding of the program itself.
Constants with big data set will definitely hinder performance because they will get included in the code memory multiple times if present in multiple locations.
05-18-2009 07:36 AM
Another advantage of using one constant and wiring it to multiple places is that if it ever needs to be changed, the programmer only has to find and change one location. If the constant was in ten or twenty place in the program and one or two were missed during a change, consider how difficult it might be to locate the error, or even to determine that an error existed! Partha's comment about placing it outside the structure also contributes to ease of maintenance by making it easier to find the constants.
Lynn