While we, well I, tend to use Perl's language level
class-based OO, it's possible to do prototype-bassed OO.
You can use
Class::Prototyped,
Class::Classless,
other modules or even write your own basic system.
What I've been meditating on is:
When is prototype OO to be prefered?
I've only used prototypes in a configuration
framework to permit overrideable defaults and per-object
methods. Also, I've done a little JavaScript.
So I'm far from an expert.
Are there particular domains or problems best approached
using prototypes?
Is there a "code smell" the suggests it's time to move
to prototypes?
Are there design problems that prototype-OO can induce?
What are the tradeoffs?
Here's my list, but I'm pulling them out of thin air:
Advantages to proto-OO:
- More flexibility, particularly at run time
- Open framework concentrating on interfaces
- Unifies instance attributes and methods (often the case)
Disadvantages:
- Slower (I have no benchmarks though)
- Action at a distance if you change a property of
a parent object (read-only objects are ok)
- More prone to dynamic spaghetti dependence (tm)
- Multiple inheritence seems difficult
Of course, with Perl you can use both approaches
within the same application. The question is when?
Brad
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.