Hari's Corner
Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and thenPHP templating systems - pros and cons
Filed under:
Software and Technology by
Hari
Posted on Sat, Dec 1, 2007 at 10:42 IST (last updated: Wed, Jul 16, 2008 @ 20:38 IST)
- Makes application logic much easier to follow and PHP code much more easier to read.
- Allows you to "skin" your website by using multiple templates. Thus the way your data is displayed is completely in the hands of designers who need no knowledge of PHP code to change the appearance of your application.
- Provides a shorter development cycle. It also allows you to plan exactly how your data should be extracted from source. It makes visualization of your application much easier by providing you quick, alternative views of presenting your data.
- Obviously it allows separation of skills as I mentioned above. A team of developers can be clearly separated into the "programmers" - the ones in charge of the PHP code, and the "designers" - the ones who actually lay out the presentation of the data.
- Using a third-party templating system is a good way to avoid "reinventing" the wheel, thus speeding up development time considerably. It also ensures that you need have no worries about maintaining the template library yourself.
- Processing of templates is an additional overhead you might wish to avoid. In spite of "fast" template parsers around (and Smarty is one of them) they still process text files in the ultimate analysis and any extra file processing increases execution time marginally.
- Sometimes you encounter situations where the application logic can simply not be separated from the content presentation. Yes, this does happen in practical development although finding examples theoritically is tough.
- Template designing can become extremely time-consuming because you are tempted to constantly refine and tweak the content presentation (because it's so easy to). As a result, if you are an individual programmer, you will find your priorities constantly shifting between coding and template development. This can be wearisome, since it involves working with two sets of files and you constantly need to co-ordinate your data fed by the PHP code with the template code.
- Using a templating system in the middle of a project forces you to rewrite or even discard large chunks of your existing PHP code. Even if you strip out all the HTML from PHP, you would need to write a set of "feeder" functions which would allow you to submit the data to the templating system in a format that it can understand. (currently I am forced to consider doing this, since the admin panel of my blogging system is completely written in the old style - PHP intermingled with XHTML).
Comments closed
The blog owner has closed further commenting on this entry.
8 comment(s)
Great analysis, Hari. Intermingling HTML and PHP isn't a good thing if it can be avoided.
Comment by (visitor) on Sun, Dec 2, 2007 @ 21:02 IST #
Comment by hari (blog owner) on Mon, Dec 3, 2007 @ 07:14 IST #
Comment by titanium (visitor) on Sat, Dec 8, 2007 @ 01:06 IST #
By the way, my blogging system is starting to take shape now.
Comment by hari (blog owner) on Sat, Dec 8, 2007 @ 08:55 IST #
Comment by Mike (visitor) on Thu, Sep 25, 2008 @ 14:03 IST #
Comment by hari (blog owner) on Thu, Sep 25, 2008 @ 19:40 IST #
Just want to ask if by looking at the source (view > source) you can determine if a website was created using Smarty? How? Thanks
Comment by Chris (visitor) on Fri, Sep 26, 2008 @ 09:03 IST #
The client (browser) gets only the processed HTML so it is not possible to determine how the site was created unless the website author puts up a notice or a link at the footer indicating the tools he's used to create the site.
Comment by hari (blog owner) on Fri, Sep 26, 2008 @ 09:12 IST #