jwcolby
jwcolby at colbyconsulting.com
Fri Sep 23 15:49:59 CDT 2011
>How do you propose fixing the problem? 1) primarily by limiting the number of globals so that there are fewer for bad actors to modify. 2) By wrapping them in property statements so that they can be easily modified to perform checks. 3) By making them a property of the module which needs to set it (if it is only modified by one "thing") and making the property read-only to the rest. There is no magic answer, just a variety of techniques to make the problem smaller and smaller. John W. Colby www.ColbyConsulting.com On 9/23/2011 4:40 PM, Kenneth Ismert wrote: >> Drew Wutka: >> A global variable will ONLY fail in the SAME way that a modular or >> procedural variable will. >> ... >> #1. 'A global variable can be changed from anywhere.... so it could get >> a bad value'. Really? So let's look at a procedural variable: >> ... >> Holy Division by Zero Batman. We just 'broke' a procedural variable! ... >> > > You're right, but for one TINY difference ... in your procedural example, > you can raise an error up the call chain, and immediately finger the bad > actor. > > In all of the global parameter schemes put forth so far, you don't get that. > The failure chain is: > 1. Good actor sets global. Time goes past... > 2. Bad actor changes global to a 'bad' value, which is accepted without > error... > 3. Other actor uses global -- BAM! BIF! POW! error. > > But who did the dirty deed? You can't easily tell. This is the crux of the > 'globals are bad' arguement. > > Without knowing WHO made each change, you're stuck with a tedious debugging > mess. > > But again, talking to the 'globals are bad' camp, I say your solutions so > far don't solve the problem. How do you propose fixing the problem? > > -Ken