One suggestion. I would prefer to have your get() routine
barf if you tried to get a non-existent attribute instead
of proceeding. This allows you to catch typos in names at
However beyond that using subroutines gets you into the
following paradox. Suppose that working with heavily
factored and organized code is 5 times harder per page of
code. Suppose that it does the work of 20 pages of
unfactored and unorganized code. If you assume that the
issue of tracking down the same bugs in unfactored code is
similar to the issue of changes made for one reason
affecting things all over the place, then that is a gain
in productivity of a factor of 4. However whenever picking
up that code I can guarantee you that you will feel that
factor of 5 issue.
As for the assumption, that is where experience comes in.
It is easy to break things into a million subroutines. What
you learn over time is how to break things into a million
subroutines that organize into clumps which present
loosely coupled interfaces to the rest of the world. After
you do that you just do not modify existing public
interfaces lightly. Add a parameter, sure. But don't
lighly assume that nothing depends on old (even old and
Also another good idea - the test suite - makes this easier
by giving you a good idea what behaviour someone else is
depending on somewhere which you didn't remember.
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.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||