Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl High School Graduation

by jarich (Curate)
on May 20, 2002 at 05:39 UTC ( [id://167771]=note: print w/replies, xml ) Need Help??


in reply to Perl High School Graduation

Comments on your OO page, some nit-picky:
  • Explain references first. Starting with OO and then saying, oh, they're just references, won't help. References are difficult. Perhaps make them an entirely separate lesson (and remember, complex references usually turn out to be the most useful
  • Explain why a hash reference is a good idea for an object. Why not an array ref? Are other references options? (yes, but discuss why we usually pick hashes).
  • You have to be more careful of case. For example you've written both this:
    my $pp=new ball("Ping-Pong");
    and this: the scalars $PP
  • Your very first new sub has no comments but is far from intuitive. Perhaps something more like:
    package ball; # things from here will be of the ball class # Makes a new ball object. sub new { # assign all my parameters my ($class, $name, $size) = @_; my $self = {}; # This will be our new object # Mark this hash ref as a "ball" object bless $self, $class; # do our initialization (add useful defaults) $self->{'name'} = $name || "unnamed"; $self->{'size'} = $size || 0; return $self; }
    is in order.
  • Your second new function is even more unwieldy. Comment and perhaps focus on shift less. (It might not be necessary if you use something like mine above)
  • All your subs below your second new function are out of alignment.

I think that there's a lot that you're taking for granted about OO and Perl OO. As this is a draft that's fine, but you need to explain more. pjf and I do Perl training courses that cover both references and Perl OO. Feel free to read over our course notes and see if there's anything there that can help you. http://www.perltraining.com.au/notes/

I hope this helps.

jarich

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://167771]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-18 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found