Re: [SMARTY] smarty templates vs. php templates

From: Date: Wed, 06 Apr 2005 14:05:17 +0000
Subject: Re: [SMARTY] smarty templates vs. php templates
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12420@lists.php.net to get a copy of this message
David, It sounds like you're really painting yourself into a corner... Why don't you do one thing I suggested: 1) calculate the amount of time it would take to build all the form widgets from scratch. Then put a dollar amount on it and put it next to using the form widgets in Smarty. It's a start. DC David Ngo had written:
We are not talking about building a new template system here. What they are proposing is just using html/php as a template which will be an include file. We would also then have to come up with our own functions for displaying listboxes, radio buttons, tables etc. Yes that sounds a lot like Smarty, but the argument is that they would not have to learn Smarty that way and the php/html templates would be much simpler since everyone at work knows php but I'm the only one that knows Smarty. Our new programmer claims that she can write the xml caching in 6 lines of code using a harvester. I find that very hard to believe but maybe she can? I really cannot rule that out immediately without seeing the code, which by the way has not been written yet. Unfortunately I do not have any actual workplace examples where Smarty has saved me that I can share. I know that it makes my coding easier and I can pretty much cut and paste presentation logic at will but this is not the hard physical evidence my boss is requiring me to come up with . We have had problems a few times because the designer was designing header/navigation/footer templates in plain php/html and I had the same templates for myself in Smarty. This caused some navigation links and pictures to be inconsistent since some pages would call different templates. And the conclusion everyone came to is that Smarty was at fault. Though really this problem would occur with any site that has 2 different sets of templates, that kind of defeats the point of having templates. DC wrote:
David Ngo had written:
At my work I work with a html designer and one other programmer. Both of them refuse to learn to use Smarty and keep arguing that we should do away with it.
Don't point out to them that they are arguing from ignorance. That will make it hard to sway them to your point of view!
My boss's take on it is that Smarty adds complexity with little benefit.
Um, having a team of programmers developing and testing a solid code base is a pretty big benefit. Who are you going to get to test and debug the proposed XML caching system? How much time and money will it take to build? Is it a critical part? If so, why not use a mature compiling/caching system instead of a new caching system?
Their solution is to just do away with the templates and instead have php include files with html in them that will act as the templates.
That sounds a lot like Smarty to me! "Php include files with html in them" is just another term for template. Besides, you can avoid using the complicated stuff pretty easily. And then it boils down to building html files with smarts.
We also have a proposed solution using xml that can replace the caching options that Smarty has built in.
Yes, the key phrase here is "proposed." Why use vaporware when you can use real, battle-tested code?
I have to come up with a few examples where using Smarty is a better solution.
Why don't you share them here?
Does anyone have any extremely convincing examples I can use to change these people's minds? All of the examples I have seen on the Smarty site and through google are very simplistic examples that could easily be replaced by php includes.
I think the key is to find the breaking point for the application you are building. That is, where has Smarty saved you in the past? And what capabilities are you going to want to add to your custom solution that Smarty already has. Another important point that people often overlook is that Smarty is very widely known and used. That will be a critical selling point for including it in your system. This is what I call "universality." It's the likelihood that others will know Smarty when it comes time for you and your co-workers to move on. If you don't go with Smarty, the company is left with a highly specific, customized solution with (very likely) no documentation, and that no one know how to maintain or develop.
I do not want to move away from Smarty because I feel it makes my code better structured, easy to read, and just forces me to have better coding habits.
Those are great reasons! Now translate them into dollar amounts for your boss. Do a conservative estimate of the time it would take to replicate some of the Smarty technology in your custom system, then multiply that by your estimated hourly wage. Then multiply that by 2-4 because we are all optimists and underestimate the time it takes to do anything custom built!
However how do I explain to someone that has never used Smarty and refuses to learn it that it is the way to go?
Let them drive it. You can't argue against someone who has a closed mind and no direct experience. Come up with an ordered list of criteria for evaluation: say, initial development time, application maintenance and expandability, code speed, separation, learning curve, documentation, "universality", etc... Each person will have different ideas of what should be at the top of this list but will basically come down to "company makes more money" and "workers suffer less pain." But, do the ranking separately for each stakeholder, and don't share rankings until the test is over. Then, clear some time in your dev schedule and devise a test mini-project to develop in Smarty and your custom template environment in parallel. This should only take 1 day to build both. Then look at both solutions with your criteria in hand. Whichever satisfies the critical criteria the best (across all interested parties) is your winner. The key is to come up with what is important to you and your company and rank it and then take a realistic view of the results.
I fear that if I can't come up with some good examples we will switch to the system of using php includes as templates which I do not like at all.
HTH, dan


« previous php.smarty.general (#12420) next »