in reply to Re: Re: OOP: Plugin Style Development
in thread OOP: Plugin Style Development
die "This isn't a Display adapter!" unless $display->isa('Display::Base'); $display->doSomething(@args);
As for your concern about contracts and enforced APIs ... Perl doesn't do that. You're just going to have to make sure with all other developers that everyone agrees on an API.
IMHO, this is a "Good Thing"(tm). More communication between developers is good.
You can do a few things in the base class to provide for interface checking. Here's a canonical way to implemental a virtual function:
Then, when a client expects foo() to be a method and it isn't overriden, you can take a "Clue-By-Four"(tm) to the offending author. (Something along the lines of "Why didn't you follow the agreed-upon spec?!?" Of course, you need one of those to have a leg to stand on .........)sub foo { my $self = shift; die "Whoever wrote '", ref($self), "' is a dork. S/He didn't overr +ide foo()!"; }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use sane Design (was Re3: OOP: Plugin Style Development)
by jk2addict (Chaplain) on Jul 22, 2002 at 20:27 UTC | |
by dragonchild (Archbishop) on Jul 22, 2002 at 20:30 UTC |