[Melbourne-pm] Interface Classes
Scott Penrose
scottp at dd.com.au
Wed Mar 15 19:17:11 PST 2006
Hey guys - a quick question on "the right way"
In OO we are taught that a Class (in Perl 5 case - Module) should
have a purpose.
It should not be just an interface you have to plug in to.
And there should not be really a Base class - from above.
But... in Perl we don't have the Interface that Java does...
So here is my question. I have a base class - let us call it "Fred".
Now I have a new class that inherits from the Base which must inherit
from the Base - ie: "Fred::Example1" ISA "Fred".
Later I make a new one "Fred::Example2" - which may be ISA
"Fred::Example1" or just a "Fred".
So now the real question - should methods in "Fred" look like this...
sub blah {
croak "Interface not implemented"
}
Or should they be...
sub blah {
... do what blah would do ...
}
Think of this like DBI. Some methods can definitely be defined,
especially if they are likely to be the default method - but some
methods MUST be implemented by the driver - so should they have one
of the above. In DBI land this would be silly - eg: Who gets top
billing ?
Another alternative is that it itself becomes its own form of a Mock
object for testing. In DBI case you would my $dbh = DBI->connect();
or something.
What are thoughts on style here?
Scooter
--
* - * http://www.osdc.com.au - Open Source Developers Conference * - *
Scott Penrose
VP in charge of Pancakes
http://linux.dd.com.au/
scottp at dd.com.au
Dismaimer: If you receive this email in error - please eat it
immediately to prevent it from falling into the wrong hands.
Please do not send me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Microsoft is not the answer. It's the question. And the answer is no.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://mail.pm.org/pipermail/melbourne-pm/attachments/20060316/e0957956/PGP.bin
More information about the Melbourne-pm
mailing list