Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Practical Programmer is indeed a classic-in-the-making.

There's another classic that's well worth reading: Refactoring: Improving the Design of Existing Code. Design will always change as you get further into the code; refactoring gives a methodology for making those changes in a way that is less likely to break existing code.

Absolutely we need to make sure that our code fits our requirements. But I'd prefer to save my compromises for optimization of the code. Constant attention to design is important, just to make sure it's at least a SMOOTH ball of mud. :)

My rule of thumb: keep documentation as close to code as possible. Keep data and formatting as far from code as possible. But no farther. If it's necessary to write code to do the formatting, the formatting code should be in its own class or template, because formatting changes so frequently.

Could you create a "TableFormatter" object with a format_row() method that is called once for each row in a table? Then it could keep track of the table rows without the records themselves having to know which row they are, just by keeping track of what color it used last.

For me, a key to orthagonality is to limit the functionality of each layer. I've recently started learning about XSLT, and one thing that I like about it is how limited it is. There are certain things which are difficult or nearly impossible to do in XSLT, which forces one to do them somewhere else (such as in a Perl script), and have XSLT handle the output reformatting alone. (You could actually handle the alternating-rows problem using XSLT, and then be totally agnostic as regards the underlying dataset.)

Anyway, hope those random musings have some value...


In reply to Re: Sacrificing Orthogonality (code) by stephen
in thread Sacrificing Orthogonality (code) by deprecated

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 contemplating the Monastery: (5)
    As of 2020-07-08 14:27 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found