Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://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...

stephen


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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found