04-23-2010 09:02 AM
smercurio_fc wrote:
Ben wrote:Globals are evil, globals are evil,...
Count me in as a devil worshiper then.
Quoting myself from above;
"
No you don't have to listen to me but I am obligated to warn you.
"
Ben
04-23-2010 12:10 PM
I will repeat what I said a few weeks ago. Globals are NOT evil. Improper use of globals IS evil.
I have developed large apps in the test and measurement world. I use Globals to hold the GPIB address of all the instruments and the PXI names of all the PXI cards amongst other things. These globals NEVER get written to. Always read only. Now what exactly is evil or wrong with this use. Ben you are speaking from the perspective of your world. There are many different situations out there. In my world, Globals are sometimes a great necessity that makes programming much simpler. I equate my use of Globals to the use of Constants in C.
04-23-2010 01:51 PM
Ok.
I have softened my warning statement a bit but it still feels like I am leaving matches laying around.
Ben
04-23-2010 03:02 PM
Ben wrote:Ok.
I have softened my warning statement a bit but it still feels like I am leaving matches laying around.
Ben
Sometimes matches serve a purpose. I do agree that a stern warning should be provided with the use of Globals and Locals. I have been bitten before by the race condition syndrome, learned it the hard way. In my opinion, the only good use for Globals is as a Constant (read only).
04-26-2010 11:47 AM
In the odd condition that I would use Globals, I use them in the same way as tbob does.
Usually, they are used ONLY if they were previoulsy used in that manner by whoever wrote the original code.
I tend to use xml files to hold the configuration data instead of Globals.
04-26-2010 12:14 PM
I have used ini files and config files to hold config data, but it is cumbersone and slow to read the files every time I want to get a GPIB address of an instrument. If I use the files, I usually read the file at the beginning of the program and store the data into a Global worm (write once read many), or when using a state machine, in a local variables cluster.
04-26-2010 12:19 PM
I thought about this this week-end.
WORM globals - (Write Once Read Many) globals are a safe use of globals provided you and only you are the developer and you remember that you used globals and already used-up your allotment of write globals.
Ben
04-26-2010 12:26 PM
Ben wrote:I thought about this this week-end.
WORM globals - (Write Once Read Many) globals are a safe use of globals provided you and only you are the developer and you remember that you used globals and already used-up your allotment of write globals.
Ben
A very practical thought, Ben. I would never use Globals in any way other than as constants or worm globals. The trick is to get others, those who might inherit your code, to do the same.
Has anyone coined the term Worm Globals yet? Or did I just invent something new?
04-26-2010 12:33 PM
tbob wrote:
Ben wrote:I thought about this this week-end.
WORM globals - (Write Once Read Many) globals are a safe use of globals provided you and only you are the developer and you remember that you used globals and already used-up your allotment of write globals.
Ben
A very practical thought, Ben. I would never use Globals in any way other than as constants or worm globals. The trick is to get others, those who might inherit your code, to do the same.
Has anyone coined the term Worm Globals yet? Or did I just invent something new?
I'll call it yours. Maybe its time to spice up your signature.
"Inventor of the WORM Global" with a link to this thread.
Ben
04-26-2010 12:53 PM - edited 04-26-2010 12:54 PM
Ben wrote:
I'll call it yours. Maybe its time to spice up your signature.
"Inventor of the WORM Global" with a link to this thread.
Ben
Like this?
How do you point to a particular post instead of the first one on a page?