something along these lines
a while ago
Other things have been written in the past too. Off the top
of my head, the major gripes people have with put-get
accessors (not lvalue or tied interface) are:
- -> becomes the only useful operator. + becomes foo->add() or foo.add().
- Side effect of above: incrementing or any += style operator becomes particularly painful
- The rich interfaces of hashes and arrays is lost when implementing datastructures as objects, an extremely common case
Like functional programming, object oriented programming
is more a state of mind than a set of tools.
There are powerful motivators for people to drop the
features of Perl for a far more simplistic language that
offers a clean, consistent object library and strict
checking. These kinds of projects are seldom done in
Perl - projects with numerous programmers. Attempting
to do these large projects without the natural inter-programmer boundaries that interfaces afford is
every bit as painful as losing hashes, automatic
stringification, and so on. Well, it need not be such
a choice: operator overloading, tied interfaces,
and lvalue methods collectively allow you to present
a portion of an OO interface as an array, hash, or so
on. An early on accepted RFC for Perl 6 (perhaps
this has changed since then) asks that hashes iteractors
be reset explicitly with a sort of %hash.reset() type
thing. Things like exists() would be made into methods
as well rather than polluting the core namespace.
Hashes have a rich interface, but as rich it is, it
will never be rich enough. Your object will present
some of its interface masquerading as core Perl features,
but after a point, you must commit to an API, and
you should do this carefully, thoughtfully, and knowledgeably. This is a topic unto itself. Designing
anything that pases the test of time boils down to
becoming a history major, studying many falls of many
civilizations. In other words, just because you can
avoid OO interfaces for a while doesn't mean you should
forever, or that you need be any less skillful with them
just because you're writing Perl instead of Java.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||