|
Helping ordinary people create extraordinary websites! |
Cultured Perl: Embedding Perl in database tablesBy Teodor Zlatanov2005-04-27
Conclusion I hope you enjoyed learning about code templates stored in a database. You may be interested in the Template Toolkit, which can make your templates much more powerful than the simple substitutions shown above. Beware, however, of making all your code a series of templates. The templates will be too complex and will become difficult to update very quickly. Make sure you balance power with simplicity, and when possible, allow both. That's the trademark of a good designer. In the case of the Template Toolkit, a good rule of thumb is to have no more than one loop and no more than three interpolated variables per template (assuming the templates are intended as one-liners). Once you consider code templates for your operations, you should look at the general MVC (model-view-controller) patterns implemented in the Java Swing toolkit, for example. There are many benefits to separating model, view, and controller; when you abstract operations as this article has shown, you can easily do the next step of separating the view and the model of your data. Even if you don't do the view-model separation, the MVC pattern is valuable in many situations, so you should take a look at how it works and what it can do for you. Have fun with your database operations and remember, TMTOWTDI! Tutorial Pages: » Put Perl into your RDBMS Design to Reach Database Nirvana » Class::DBI Capabilities » Setting up Tables » Embedded Deletion » Embedded Modifications » Compatibility with Other Languages and Alternative Approaches » Conclusion » Resources First published by IBM DeveloperWorks
|
|