Hi Samir -
> > You're right, variable scope does not have much to do with possible conflicts when fields and variables have the same name.
> > But the dogma not to use Public variables has to do with object-oriented programming vs procedural programming, especially the idea of encapsulation.
>
> Agree on procedural programming That is how I work,
>
> but i cannot find what is the relation if I used Public Variable in an application to use it on form and not using Public Variable is procedural programming. where is the wrong in that?
When I moved from FoxPro 2.x to Vfp, I was confused by object-oriented postulates and yet another learning curve.
Later, when I somewhat got used to it, I did not want to look back anymore.
For instance the concept of encapsulation impressed me:
in context of any code at any time I could createobject() whatever derived from a complex class that I had created previously, and got a very easy interface -
say only one or two methods being visible via Intellisense myObject.DoImportantStuff(param1, param2).
All the complexity, a lot of internal methods and properties of that class were hidden, it's just one call and the result comes back.
If that class would have required any global variables, the encapsulation would have been broken and the calling procedure would have suddenly become much more complicated, caring for dependencies and so on, and two lines of code would have been ten or twenty.
So I thought Hey, OOP is a good thing :-)
Regards
-Stefan