in reply to has-a in Perl

Beware circular references. They are very easy to create if you start passing references to the current object you are in, into other sub-objects, which may hang onto them.
Your current plan also sounds more like the objects are inter-dependant, rather than one inheriting from the other.

Widget and Widget::Checkbox are not separate objects, merely one object spread over 2 packages. I would suggest separating them, keep Widget as a base class, which knows nothing about Widget::Checkbox. Let Widget::Checkbox (and Widget::Radio and Widget::Foo extend Widget)

In one of my current projects, I use a base object, which contains these methods:
# initialize/bless/ect $obj->new(); # serialize the objects data (currently with Storable) $obj->serialize(); # get/set params as in CGI.pm $obj->param(); # deserialize the objects data (Storable) $obj->deserialize(); # xml format $obj->to_xml(); # de-xml $obj->from_xml();
All of my other data objects, inherit from this object. A few, override the object's methods such as param, if I need a specific behaviour. (such as throwing an exception if I get bad data passed in)

Replies are listed 'Best First'.
Re^2: has-a in Perl
by chromatic (Archbishop) on Apr 18, 2005 at 20:46 UTC

    If that were me, I'd use roles instead of inheritance. (Class::Roles).

      Thanks, I'll have a look at them.