BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Are globals really THAT evil?


smercurio_fc wrote:

Ben wrote:

Globals are evil, globals are evil,...


Count me in as a devil worshiper then. Smiley Very Happy


 

Quoting myself from above;

 

"

No you don't have to listen to me but I am obligated to warn you.

"

 

Smiley Very Happy Smiley Very Happy

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 21 of 89
(12,931 Views)

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.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 22 of 89
(12,915 Views)

Ok.

 

I have softened my warning statement a bit but it still feels like I am leaving matches laying around. Smiley Wink 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 23 of 89
(12,900 Views)

Ben wrote:

Ok.

 

I have softened my warning statement a bit but it still feels like I am leaving matches laying around. Smiley Wink 

 

Ben


 

Sometimes matches serve a purpose.Smiley Wink  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).

 

- tbob

Inventor of the WORM Global
Message 24 of 89
(12,894 Views)

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.

0 Kudos
Message 25 of 89
(12,843 Views)

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.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 26 of 89
(12,844 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 27 of 89
(12,842 Views)

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? Smiley Surprised

 

 

- tbob

Inventor of the WORM Global
Message 28 of 89
(12,837 Views)

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? Smiley Surprised

 

 


 

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 29 of 89
(12,834 Views)

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?

 

Message Edited by tbob on 04-26-2010 10:54 AM
- tbob

Inventor of the WORM Global
Message 30 of 89
(12,827 Views)