In perl, there isn't an "interface" keyword. The only built-in construct (that I can think of) that has this interface substitution is the "tie" function, with which one can subsitute different implementations of arrays, hashes, etc. There are many modules that use this principle, e.g., DBI.
I'm of the opinion that to qualify for a real separation of interface and implementation, one should be able to switch an implementation without changing a single line of client code. In java, this is often accomplished via the Factory pattern (i.e., the client never need to call "new", which would require the client to know the name of implementation class.) I haven't looked enough to see much use of that pattern in perl, I assume that is not really necessary since in perl even the class name can be a variable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Separation of interface and implementation
by eyepopslikeamosquito (Archbishop) on Dec 20, 2004 at 08:46 UTC | |
by johnnywang (Priest) on Dec 20, 2004 at 18:52 UTC | |
|
Re: Separation of interface and implementation
by demerphq (Chancellor) on Dec 20, 2004 at 10:46 UTC | |
|
Re: Separation of interface and implementation
by Thilosophy (Curate) on Dec 20, 2004 at 11:19 UTC | |
|
Re: Separation of interface and implementation
by chromatic (Archbishop) on Dec 20, 2004 at 18:55 UTC |