Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You have hit upon something most experienced developers call "Separation of Concerns". It's the underlying principle behind MVC - Model / View / Controller. (It's called by other names, but that's the most popular.) It was also a driving force behind creation of OO methodologies.

This is usually seen in Perl with the use of templating systems, like HTML::Template or Template Toolkit, for separation of Perl (business logic and engine, or Model / Controller) from output generation (View). Other distributions, such as SQL::Catalog, can help with the separation of SQL (data logic, or Model) from Perl (business logic and engine, or Model / Controller).

Many people, including myself, tend to provide for a different separation between HTML, CSS, and Javascript. I look at the View layer as generally composed of three elements:

  • Layout (HTML)
  • Style (CSS)
  • Client-side interaction (JS)

Perl tends to not be involved with those at all, except for ease of maintenance in the assembly of the pieces. So, I tend to have different directories for each (/templates, /javascript, and /css). So, if I were truly separating out the five languages, I would have the following directories:

  • /lib (Perl modules)
  • /sql (SQL catalog) (I tend to not use this one, preferring to embed my SQL within a separate Perl module designed specifically for database interaction.)
  • /templates (H::T or TT templates that bring together the various View components, plus contain HTML)
  • /javascript (Client-side interaction)
  • /css (Style sheets)

Most examples you tend to see are for complete newbies, who just want something to get them up and running quickly. The reason for that is that newbies need to have instant gratication, or they give up. Later, if they are interested, they will do what you're doing - come to those with experience and ask for advice. At that point, you'll improve your code. :-)

We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

In reply to Re: Code Conflation: Considered Harmful? by dragonchild
in thread Code Conflation: Considered Harmful? by rvosa

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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (2)
    As of 2018-01-21 03:42 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (227 votes). Check out past polls.