Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
(Posted based on private conversation with tye.)

To me the key concept is abstraction layers. Perl offers a lot of ways to create an abstraction layer. As long as you have and think in terms of abstraction layers you will find cascading defaults trivial to implement.

I have found this to be true even if the abstraction layer is something as simple as storing stuff in a hash. (Start it at the default, then overlay changes in hash slices.) The second pass at an OO answer in RE (tilly) 4: Handling cascading defaults shows this kind of abstraction allowing the over-riding of defaults set during your constructor in a method call. (OK, that was in an OO example, but the principle of how I cascaded that time was not OO specific.)

Another form of abstraction is provided by using references to subs rather than subs directly. OO is yet another. All of these can solve cascading defaults quite smoothly, for the same basic reason - your code goes through a level of indirection which anything you want can be overridden in.

Now what does OO provide above and beyond abstraction? Well it provides an entire mental framework for how to organize your thoughts about problems. For some people this fits well. For others it doesn't. I am a person who is both competent at thinking that way but doesn't particularly enjoy it or find it a natural fit. (YMMV of course!) I don't want to track down the link, but at IWETHEY we had a conversation about this once. I thought that OO reminded me very much of an area of math called category theory, both of which I disliked. Ironically someone else there knew both, agreed they were similar, and liked both of them. :-)

I won't give a detailed critique of my feelings. Most of it wouldn't make sense to most people here because I compare it to my experiences with graduate level math, which is probably not a particularly common experience base in these parts. :-)

However if you look at what I write you will find that for me abstraction layers are a theme that comes up quite often as a motivating principle. You also see it in some of my favorite links, such as Linus on Portability (linked on my home node).

In reply to RE (tilly) 2: Handling cascading defaults (abstraction is great!) by tilly
in thread Handling cascading defaults by markjugg

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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, 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (4)
    As of 2021-01-23 02:28 GMT
    Find Nodes?
      Voting Booth?