> > Most of the work I do is with applications written by others. It's my experience that every time I've encountered an application that uses public variables, the application also has other significant design flaws. The applications that are well-designed in other ways (properly normalized tables, coding standards in place, a single architecture used throughout the application rather than changing it every time the programmer learns something knew, etc., etc.) pretty much never use public variables.
>
> Finding a wrong approach that a previous programmer did, is not an evidence for wrong use.
Read what I wrote again. I'm saying that, in my experience, using public variables usually is a sign of a programmer who either isn't very good, or doesn't know FoxPro very well. Not 100% of the time, but usually.
If someone knows what they're doing with a public variable, I'd expect to find a comment explaining why there's a public variable in this case and why a private or local or property of an application object won't work.
> > Samir - I understand that you've developed a way that works for you, but I think you should look at the group of people telling you to avoid public variables. They include the authors of a number of the best-known and most widely-respected books on VFP. Perhaps we have lots of experience (nearly 20 years with Fox, in my case) that has formed our opinions on the subject?
> >
> > Tamar
>
> I have a less than one year experience of fixing other code (10 months)-when I asked to change the code for whole accounting module - so I don't have a big experience of looking to other code like you do. but i know this.
>
> when i start as a programmer in a company, they give me a job and i guess it was about reading text file and do some manipulation on it. after i finished my code i deliver it to the head programmer, the only comment i got is why i used log name for my form.
>
> #1 when there is a company with 15 programmer working on 1 software, do you expect them to use the same concept?
In that situation, I expect there to be a document that tells what that companies programming standards and practices are, and then I expect everyone to follow them. (Okay, I don't really expect that; I hope for it.)
> #2 the issue with public is when you are debugging other's apps? you are complaining about PUBLIC because you are to much fixing other code, and you had finding that PUBLIC causing the trouble, so advising other about not using PUBLIC will make it easier for you to do your job?
>
The issue with PUBLIC is that it increases the risk of your application going wrong. Applications tend to have long lives. Even if you're the person who comes back to the application in 5 years to change something, public variables make it more likely that you'll make a mistake.
Samir - the people who are telling you to avoid public variables (me, Andy, Jim, Mike) have years and years of experience with FoxPro. We've learned the hard way what kind of trouble they create. Learn from those who've walked the path before you.
Tamar