DWUTKA at marlow.com
DWUTKA at marlow.com
Wed May 18 12:11:57 CDT 2005
John, I never said that programmer convenience is why you should use a global variable. If you need a variable to be seen and used throughout your application, then a global variable should be used. Drew -----Original Message----- From: John W. Colby [mailto:jwcolby at colbyconsulting.com] Sent: Wednesday, May 18, 2005 9:33 AM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Global Variables Thanks I started my programming experience trying to get an old star trek program to run on an old data general mini with 16kb of ram. It wouldn't load and AI printed it out on a roll of TTY paper and it stretched 12 feet across the floor. In the basic it was written in, functions and subs did not even exist so everything was global and everything was a go to. I sat down and drew connecting lines between the goto line of code and the destination. Until you do something like that you cannot truly appreciate the term "spaghetti code", but a pile of spaghetti is exactly what it looked like. Thus when I moved on to Turbo Pascal where functions existed, and all variables had to be declared before it could be used, and variables were strongly typed and you couldn't accidentally pass a float into an integer, needless to say I was in heaven. All tools exist for a reason. I appreciate good programming practices and I always look for techniques to make my coding style stronger. Tools like strong typing, naming conventions, scope, classes etc are just that, tools and nothing more. You can accept them or reject them. I have had to clean up behind people who reject them and it isn't fun. To go back in and retrofit a working program that uses a ton of globals probably isn't worth doing. On the other hand, when designed from scratch, most programs don't really need all those globals, they were used for the programmers convenience. "Programmer convenience" is not a good reason for bad practice, regardless of what our young Jedi Knight would have you believe. Saving keystrokes is the absolute worst reason for not doing things right. And I am always suspicious when there is something like Globals which I am quite easily able to largely avoid, yet someone claims their program "just has to have millions of them". John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav Sent: Wednesday, May 18, 2005 10:01 AM To: accessd at databaseadvisors.com Subject: [AccessD] Global Variables Thanks Thanks to John, Drew and All For a long while now I have been reading the postings on the list about Global variables "bad practice", "avoid using them", etc. I have a couple of old programs that have been running cleanly for years and they use a large amount of global variables. Many of the variables are carried through various phases of the project and some are regularly being changed/refreshed. Yes and some are integers. After reading "bad practice" I got worried that I was doing something majorily wrong. I sat down and tried to figure out how I would carry some of these variables forward. It amounted to a large increase in the code necessary to do this and in some cases it involved complex/messy error trapping vs simple declaring the variable and trapping for errors. Anyway after this discussion I am now aware of what is meant by and in what circumstances individuals deem it "bad practice" and that on the otherhand handled properly it is not necessarily a bad thing. Another thing to keep in the back of my mind when developing an application. Old dog new tricks. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com