pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:
In my brief Java experience many years ago, I ran across what they called 'interfaces'. These are classes that describe a set of methods but don't actually define them. Instead, each of those methods must be overridden by any subclass. Failure to override those methods results in a compile time error.
An example might be a 'Shape' class as an interface. Every shape has an area, but every shape ('circle', 'square', 'triangle'...) computes that area differently. With an interface, you enforce the requirement that any subclasses have an 'area' method. If ($circle->isa('Shape')), you know it's going to have an 'area' method written specifically for whatever kind of shape that is...
As I'm working in perl, I keep trying to build things that do that. I'm dumb enough to build a class and forget to override that one rarely called but vital method. So, I like things that yell at me during compile time.
Any suggestions?
Thanks!
--Pileofrogs
Update: The key to what I want is that it complains at compile time, or at least object initialization. Complaining when I attempt to call the method is too late...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Java Style Interface Objects?
by stvn (Monsignor) on Feb 03, 2006 at 17:59 UTC | |
|
Re: Java Style Interface Objects?
by Tanktalus (Canon) on Feb 03, 2006 at 18:13 UTC | |
by chromatic (Archbishop) on Feb 04, 2006 at 04:00 UTC | |
|
Re: Java Style Interface Objects?
by izut (Chaplain) on Feb 03, 2006 at 17:38 UTC | |
|
Re: Java Style Interface Objects?
by chromatic (Archbishop) on Feb 04, 2006 at 04:00 UTC | |
by stvn (Monsignor) on Feb 04, 2006 at 16:00 UTC | |
|
Re: Java Style Interface Objects?
by Tuppence (Pilgrim) on Feb 03, 2006 at 22:48 UTC | |
|
Re: Java Style Interface Objects?
by duckyd (Hermit) on Feb 04, 2006 at 00:56 UTC |