I would agree with you and Bret on this, on general principle... except:
What you say is all very well and good, until -- being a newbie -- you
run into a problem that you cannot resolve, and which seems to make no
sense. For some reason one of your applications starts using values
from another... because you have them stored within the same Rails
project (for one common example), and you used globals.
And please keep in mind that people use Watir for things other than
testing!! Without trying to be insulting, I must be honest and
state that I find the strict testing-centric view to be more than a
little myopic.
Programmers for generations now -- quite literally human generations --
have warned against using global variables, and they have had excellent
reason to do so. Those reasons have not changed. Globals have uses, or
they would not exist. But usually, using them is bad practice.
And I did not explain or have to explain this concept in depth; the
basic idea was to change a $ to an @. That does not have to be attached
to deep understanding in order to be useful.
You say you were not trying to shoot the messenger, but this messenger
has a definite impression of getting shot at, for giving someone good
advice which I had very good reason to give the way I did. Why could
you not just leave it alone?
Lonny Eachus
=========
Word to the wise..
On 01/09/06, Lonny Eachus <[EMAIL PROTECTED]> wrote:
David,
sometimes these people forget what it is like to be a newb, and
give you specific information might be helpful *IF* you had a context in
which to put it. From what you say, it appears you need some more
general information first.
[snip]
$ie.link(:id,
'sessionDialogCancel').click
However, I will caution you that it is usually not a good idea to use
global variables like $ie. In the vast majority of cases, you will want
to use an instance variable instead, which uses the @ sign. So rather
than $ie you would have @ie.
I hardly think that bringing up the difference between global and
instance variables to someone who doesn't know how to start IRB is a
good idea right now. I think you should follow your own advice and
keep things simple right now.
I don't consider myself a newb anymore but I still can't be bothered
working out the difference between global and instance variables in my
scripts. $ie works quite nicely for me and I am really not interested
in sorting out the difference right now. Global/class/instance/local
variables all have their place and everyone has their own ideas about
how to use them based on their level of programming experience. Do you
really think this is the right time to spring them on David?
I remember all too well the frustrations I went through in the
beginning trying to figure out Ruby and Watir and getting advanced
advice like yours above that had almost no meaning to me whatsoever
from where I was coming from.
Points for hitting the target, but you missed the bullseye. (i.e. added
to the confusion factor) Just a friendly reminder. (I'm not shooting
the messenger, just letting you know that I don't believe the message
was helpful this time.)
Cheers. Paul.
(The recent post-newb who's more interested in solving testing problems
with scripts than learning to become a programmer.)
|
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general