Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Not quite an OO tutorial

by lostjimmy (Chaplain)
on Feb 23, 2011 at 16:00 UTC ( [id://889811]=note: print w/replies, xml ) Need Help??


in reply to Not quite an OO tutorial

I think this is a great tutorial on how OO and inheritance work within perl; however, I don't think this is a great example of inheritance. This would be akin to making a vector class, then having specialized vectors that simply initialize the list with a different set of items.

A more sane approach would be to simply use the base class and pass it the list directly. The module could also provide pre-created instances or creator methods for convenience. In fact, you already show that with the $tense object.

Replies are listed 'Best First'.
Re^2: Not quite an OO tutorial
by GrandFather (Saint) on Feb 23, 2011 at 19:35 UTC

    Indeed! Inheritance is an occasional thing and finding good succinct examples is hard. However the example isn't quite as bad as a first glance may suggest. The virtue in providing derived classes here is that you don't have to repeat the same list of values if you want to use the same object type in multiple places. There are however many other ways much the same result could be could be achieved that don't require OO let alone inheritance.

    True laziness is hard work

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2025-11-11 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.