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

Re: Code Conflation: Considered Harmful?

by dragonchild (Archbishop)
on Sep 11, 2004 at 02:36 UTC ( #390227=note: print w/replies, xml ) Need Help??

in reply to Code Conflation: Considered Harmful?

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

  • Comment on Re: Code Conflation: Considered Harmful?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://390227]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2018-06-22 15:51 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.