One of the first things I was told in OO is to separate the interface from implementation. In languages like java, which supports the "interface" keyword, this is kept almost religously by some people. I recenlty looked at the source code of the popular Bittorrent client Azureus, almost every thing comes in pairs, e.g., IFoo.java and FooImpl.java. Of course, all the java standards from Sun are really just interfaces. My understanding of the reason for this separation is so that people can substitute a new implementation for the same interface. This is very handy for such things like XML parsers, and the logging API.
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.