An interface is a kind of "contract" that need to be respected by all the classes that implement that interface. All those classes should have the methods specified by the interface and those methods should have the same signature (they are able to receive the same parameters types).

Perl is not a strongly typed language, and the subroutines in perl can receive any number of parameters and they can be of any type.

In perl, the program don't enforce any type checking, but the programmer must do it. If the programmer wants to be sure that one of his classes respects some rules, define some methods of a certain type, and so on, then he should make the program in that way. If he doesn't do it, the program won't give an error telling that he doesn't respect the "contract".

Sometimes this is an advantage, and sometimes it is not...

Octavian

----- Original Message ----- From: "Paul Lalli" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Wednesday, August 01, 2007 10:22 PM
Subject: Re: Programming an interface with Perl


On Aug 1, 2:20 pm, [EMAIL PROTECTED] (Rafael Morales) wrote:

I'm using some design patterns (MVC, Observer, Strategy), with Perl,
however I see that I need to create some interfaces (watching examples
in Java and C++), but I don't know how to create these interfaces with
Perl, for example in Java this is done with this:

   public interface SomeName () {
       # some code
   }

Is this possible with Perl or is there any other way for do it ???

For those of us who are Java-ignorant (and mostly proud of it),
perhaps you could describe what it is you actually want to do, rather
than just telling us how you would do it in another language.

"Interface" as a generic word means something completely different
than it means as a Java keyword, and I don't at all remember from the
one semester of Java I took 7 years ago what that meaning is.

Paul Lalli


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to