Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Refactoring webcode to use templatesby kcott (Archbishop) |
on Jan 31, 2021 at 13:02 UTC ( [id://11127711]=note: print w/replies, xml ) | Need Help?? |
G'day Bod, [Note: Your question is very generic, which is fine. Accordingly, my suggestions are also generic: you'll need to adapt these to your requirements.] "... written entirely in Perl ... HTML, CSS, JavaScript, etc hard coded along with the functional logic." Before doing anything else, you should separate all of these concerns. There should be no "HTML, CSS, JavaScript, etc" in your Perl code. You probably want: (templated) HTML in *.tt; CSS in *.css; JavaScript in *.js; and so on. As with any sort of strict rule, there will be exceptions; for instance, you may need to toggle a CSS display property in JavaScript to handle a "show/hide" function. Here's a few general pointers:
Your template would look something like this:
"What are the hidden pitfalls that could trip me up and suck up vast amounts of time?" Following my pointers above should mostly avoid these; I wrote them with this question in the back of my mind. In my (not inconsiderable) experience, one of the biggest pitfalls in any software project is: "I'll just leave that for now and fix it later."; which is often followed by the famous last words: "That should be quick and easy to do.". If it is indeed quick and easy, do it now; however, that often turns out not to be the case and shortcomings, or even bugs, plague many subsequent production versions. Get it right once, then spend your subsequent time on things vastly more interesting than tracking down bugs or trying to refactor your refactorings to get what you wanted in the first place. In closing, this sounds like an interesting project and I wish you good luck with it. — Ken
In Section
Seekers of Perl Wisdom
|
|