Re: intro

[email protected] (Peter Scott)
Newsgroups perl.trainers
Message-ID <[email protected]>
At 11:25 PM 10/29/99 -0400, John Porter wrote:
>Peter Scott wrote:
> >
> > I don't
> > even mention dynamic variables until the object-oriented class I'm
> > currently designing for a day 4, when it's kinda unavoidable :-)
>
>Huh?  I write plenty of OO code, and I find the need for global
>vars very rare.  But what, IMHO, *is* unavoidable is the occasional
>need to
>
>         local $/ = '';
>
>         local $" = ', ';
>
>         local $^W;
>
>         local $_;  # for some loops
>
>and so on.  This is what makes globals truly unavoidable.

I don't mention those.  In 3 days starting from scratch one has to leave 
some things out, and I find I can leave those things out.  There are other 
ways for people to read a whole file into a string and insert commas 
between list items, and anyone who wants to selectively disable warnings or 
save $_ probably can find out how without my having to perplex a whole 
class with the quagmire of package variables, especially magic ones.

On the other hand, teaching OO is the first time I mention packages, and 
the concept would be somewhat flat without demonstrating how namespaces 
separate variables.  Can't do that with lexicals.  Even though I then go on 
to demonstrate how good OO code doesn't use said variables, the notion of a 
package needs concrete, easy-to-understand illustrations.

Some things have to be approached obliquely.  Clearly, use fields and 
pseudo-hashes are the way to construct instance data, but that's just not 
the way to start out teaching OO Perl, IMHO.  So I get at it the 
old-fashioned way first.  Sort of the pedagogical equivalent of phylogeny 
recapitulating ontogeny...

Of course, TIMTOWTTI...


--
Peter Scott
Pacific Systems Design Technologies
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.