Re: Public variables - when?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: gerry (germ_at_hotmail.com)
Date: 03/10/05


Date: Thu, 10 Mar 2005 08:02:28 -0500

My last comment on this , what I consider , non-issue.
I really don't have any opinion on the use of global's one way or the other.
I tend to have a single application or environmet object declared globally ,
and I have also used the mention global variables for reports. If you don't
like it , don't do it - if you do , do. Spouting you zealous views so
vehemently for the world to see is not a pretty sight.

To talk about strict OOP within VFP is a ridiculous argument.
VFP by nature is not OOP , it may support OOP but it isn't OOP itself - if
it is , then to what class does the STRCONV() method belong ? or the
TRANSORM() method ? ....

further comments inline

"Eugene Vital" <dontwantany@news.com> wrote in message
news:O90KKBQJFHA.2736@TK2MSFTNGP09.phx.gbl...
> Tim Witort wrote:
> > And _SCREEN and _VFP are other global variables. Making your
> > application object a property of another global variable is
> > a ridiculous action whose only purpose seems to be servicing
> > your "global-phobia." You just add more complexity to your
> > application yet are still dealing with global variables.
> > If you question whether _VFP and _SCREEN are global variables,
> > take a look at the help file - it is quite clear that they are.
> >
> It isn't a phobia.

hmm - sounds like it to me.

>
> What complexity?
> hmm
>
> goApp.Usrername
> .vs.
> this.oApp.Username

this , exactly which this are we now referring to ?

>
>
> VFP has varaibles that are available to me, I just use them. Why create
> yet another global variable?
> >
> >> Ever heard of a Singlton Pattern?
> >
> >
> > Yes. It's a design pattern all about having just one global
> > instance of each of your classes. Do you favor or
> > oppose it? It implies that global variables are a necessary
> > thing.
> >
>
>
> Nope, has nothing to do with global variables.
>
> If I ask my application classfactory for an object reference it know if
> it is a single instance object and just returns a reference to an
> existing one if one exists, otherwise it creates it and can store a
> reference to it in a member property.
>

noticing the total lack of static class methods in VFP's OOP implementation
, where exactly does this class factory reside ? A globally available
procedure you say ? or perhaps a piece of reused code that checks for the
existance of an application object as a property of some other globally
available object ? damn - there is that anti-oop global word again.

>
>
>
> >
> >>>Public variables to have their place.
> >>
> >> Maybe in a VB app they do but not in VFP ;)
> >>
> >>
> >> If you are still thinking Global variables then you need to
> >> revisit OOP
> >>design. (IMHO) :)
> >
> >
> > With all due respect. You don't seem to know what you're
> > talking about. OOP relies more heavily on global variables
> > than procedural coding.
>
> With all due respect it is you who doesn't seem to know what your
> talking about. I haven't programmed a global variable since VFP3 came
> out circa 1995.

so ?

>
>
> In case you didn't know it, objects
> > (instances of classes) that are visible to the entire application
> > are global variables.
>
> You only need ONE and ONLY one.

hmmm , vfp itself seems to think you need more than one - this thread has
been mentioning two of them from the very start _VFP & _screen. If you look
in the help under "System Variablesin Visual Foxpro" and you sill see a list
of 40 or so system variables which are defined as : "System variables are
built-in variables that Visual FoxPro creates and maintains automatically.
They are PUBLIC by default"

notice the functional encapsulation between these 2 objects, I think that
you would be hard to put to find any OOP proponent that aspouse the virtues
of creating anything more than a single purpose class whos purpose is to be
one all encompassing global object that is all things to all 'people' (?)

>
> Procedural programming can more easily
> > avoid globals since universally used code can simply be
> > executed via a function call.
>
> not even close.

huh - i would say dead on the mark.

>
> In an OO system, the code is
> > in methods. To call a method, you need an instance of the
> > object (a variable) that implements the method. So, in order
> > for this method to be universally available, the object
> > must be persistent and global.
> >
> Your way off base here man, when I declare a variable as LOCAL it is
> local to that method, when the method ends the variable is released.

talk about off base , how did method variables and their scope enter into
this ?
Tim's statement is 100% accurate. Using OOP, the only way to invoke a
universal method is to have access to a universal object.

>
> Again, there need only be one Global.

ok , so after all that - you do agree that global variables/objects are
useful ?



Relevant Pages

  • Re: Global Variables in OOP and Python
    ... I have questions about global variables in OOP and Python ... be accessed by a number of classes that exists in separate namespaces ... You can even add runtime parameters to the module during your initialization code, and those will be available wherever Parameters is imported: ...
    (comp.lang.python)
  • Global Variables in OOP and Python
    ... I have questions about global variables in OOP and Python ... be accessed by a number of classes that exists in separate namespaces ...
    (comp.lang.python)
  • Re: Global Variables in OOP and Python
    ... > I have questions about global variables in OOP and Python ... > in all of the files (namespaces) where it is needed. ...
    (comp.lang.python)
  • Re: OOP with FORTRAN
    ... looking back at some very old numerical code OOP appears. ... > are grouped by and manipulate data in named COMMON blocks. ... In OOP the member variables do look a bit like global variables: ...
    (comp.lang.fortran)
  • Re: Public variables - when?
    ... > _screen.Addproperty('oApp', oApp) ... And _SCREEN and _VFP are other global variables. ... i x dot n e t c o m dot c o m ...
    (microsoft.public.fox.programmer.exchange)