Post by Andrew ShimminOk ... I think I can see the problem, however I still do not have
the full context of the quotes.
The context of the controversy (which was the reason for Frank to put it
in here) started in "getting started" in Bruce R. Roland's thread "Can't
seem to get single2.wfm code to run right" where Geoff Wass in his
posting of Nov. 25 06:21 news://news.dbase.com/***@news.dbase.com
pointed the usage of PUBLIC variables:
"It sounds from your description that you are using
PUBLIC variables with OOP programming. This is not a
recommended thing to do if you are doing it. OOP is
based on the concept that every object is a independent
unit. It contains or receives directly everything it
needs. It should never rely upon things in its
"environment" like we often did in the old days
of procedural programming in the DOS versions of dBASE."
When Bruce asked back, I jumped in and did second this news://news.dbase.com/***@news-server and tried to explain
why PUBLIC variable should be avoided in OOP dBASE in any case.
On a posting by Bruce asking back, Frank jumped in recommending hanging
variables to _app as an "equivalent of public variables".
This to me did not seem too good a suggestion, especially for a user who
is not yet to deep in OOP-programming.
So I replied saying
"... It's OK to attach some centrally used *OBJECTs*
(which are used in an application *throughout*) to
"_app."
But placing any "properties" just for handling problems
with the scope of variables there is as bad as using
PUBLICs. Just very poor design. As I used to say/pray
(just to quote myself <gbg>): "Hanging properties at
"_app." is nothing but using OOPish painted PUBLICs".
The one is as bad as the other ..."
After some a number of further postings on a remark of Geoff (who shared
my approach to the issue):
"As I described above, it is the suggested alternative
to public variables."
Post by Andrew ShimminPost by Frank J. PolanNO! NO! NO!
Hanging things to "_app." is no *alternative* at all.
It's just the very same bad behaviour (or should I say what I
really think: "the very same nonsense"??)
I admit that this - written very late in the night in angry mood - was
not only a bit overdrawn. {siiiigh}
That Frank just used this quote (without the context) IMO is really
tendentious. It was clear for all participants of the discussion that I
did only object to using properties of _app in the same way (as an
equivalent for) PUBLIC variables.
There can be no doubt that I never objected to the usage of *objects*
attached to _app, when used carefully and "thrifty as a Scotchman". And
Post by Andrew ShimminPost by Frank J. PolanFor instance, I used _app variables a fair bit in the past, but no
more.
I have learned how useful it is to have a properly
encapsulated object (no external dependencies), so I
make the effort to do it.
---------------------------------------
Yes, the _app can be useful. I am not saying you
absolutely shouldn't use it (this is where I differ
with Rainald), but I am saying you should try to not
use it or at least use it very prudently. As I said, by
avoiding _app properties, PUBIC variables and your
runtime tables leads to better object-oriented programming.
Encapsulation is part of OOP and relying upon values
which are external to the object (ex: _app properties)
breaks encapsulation. A fully encapsulated object is a
more reuseable object. It allows the object to be tested
independent of the independent of the external values
it relies upon. If you start sub-classing (a.k.a.
extending) over and over a class which has a reliance on
an _app variable, you may easily forget this external
dependency when you are trying to debug the offspring.
If code is going to be fully encapsulated the author has a point.
This is my *main* point.
Hanging properties to _app IMO is hardly different at all from using
PUBLICs - as I use to say "just OOPish painted PUBLICs".
Post by Andrew ShimminI use the _app object to ONLY hold application object properties,
everything else is held as a property in an object or as a
local/private variable for execution sequence control only.
Values held in objects is a better way. Still there may problems be
arising if one works with subclassing.
Someway it's still breaking OOP-basics and may be seen as neglecting the
fact that classes should be "self-contained".
Post by Andrew ShimminGetting your head around encapsulation can take time and "hanging
variables off the _app object" is a good way to learn it.
Eventually the penny drops and the OBJECT object becomes very
useful.
Each developer is at a different stage of their OOP learning curve
so different strokes for different folks.
I fully agree.
Rainald
Post by Andrew ShimminPost by Frank J. PolanAndrew
Here's a few quotes from the ng. The first is the one that annoyed
me and prompted my question. The others are more moderate but I'm
still trying to find why it's not recommended for the way I, and
the others who responded here, are using it
Thanks
Frank Polan
---------------------------------------------------------------------
-------------------
Post by Andrew ShimminPost by Frank J. PolanNO! NO! NO!
Hanging things to "_app." is no *alternative* at all.
It's just the very same bad behaviour (or should I say what I
really think: "the very same nonsense"??)
-------------------------
For instance, I used _app variables a fair bit in the past, but no
more.
I have learned how useful it is to have a properly encapsulated
object (no external dependencies), so I make the effort to do it.
---------------------------------------
Yes, the _app can be useful. I am not saying you absolutely
shouldn't use it (this is where I differ with Rainald), but I am
saying you should
try to not use it or at least use it very prudently. As I said, by
avoiding _app properties, PUBIC variables and your runtime tables
leads
to better object-oriented programming. Encapsulation is part of OOP
and
relying upon values which are external to the object (ex: _app
properties) breaks encapsulation. A fully encapsulated object is a
more
reuseable object. It allows the object to be tested independent of
the ---------------------------------------------------------
On Sat, 29 Nov 2008 08:39:34 +1100, Andrew Shimmin
Post by Andrew ShimminWhat topic in the "Getting started" newsgroup are you referring to?
The _app object is unique to each instance of an application
controlled by the runtime, so using it for variable management is
a good strategy and will pose no problems among multiple
applications and multiple users on the same system. I have used
it extensively for years and had no problems.
Running multiple applications controlled by the IDE will cause
problems since the _app object is no longer unique to each
instance of the application.
regards, andrew
Post by Frank J. PolanThere has been some discussion in the Getting Started group
about the inadvisability of using Public variables and _app
objects
Public variables - no problem - never used them even in the DOS
version
I'm reporting my question here about the use of the _app object
because I'm seriously interested in any potential downside in
the use of the _app object in the _specific_ example I've used
-------------- original question <snipped> ---------------
Maybe a new thread, but I'd be interested in why you don't agree
with using the _app object as dBASE seemed to design it -
system/application wide CONSTANT values/settings
In a compiled app, after a successful login, and only one login
per user/PC, the following can't change -
userid, security level, physical location.
-------------------------------------------------------------------
---------------
Post by Andrew ShimminPost by Frank J. PolanPost by Andrew ShimminPost by Frank J. PolanThe above values are checked as required when opening a menu
item or form
Thanks
Frank Polan