NYCPHP Meetup

NYPHP.org

[nycphp-talk] To Smarty Or Not to Smarty: That Is The Question

Ophir Prusak prusak at gmail.com
Thu Sep 14 10:28:33 EDT 2006


I used to teach smarty for zend.com.

Based on your comments and the comments from other people, I'd like to
split your post into three questions:

1 - Should I be separating my "business logic" from my presentation
layer / presentation logic.

2 - Should I use Smarty (or some other solution) in order to separate
my business logic and presentation.

3 - Should I be using an OOP solution.

Question 3 is beyond the scope of this answer, so lets just look at
questions 1 and 2.



1. Should I be separating my "business logic" from my presentation
layer / presentation logic.

For the most part, the answer YES.

Your comment of:
> I also cannot stand the editing of multiple documents, both containing bits
> and pieces of logic - I know, one is application logic, the other is display
> logic.... is this really logical?  Bouncing between documents does not seem
> efficient, and it also seems quite possible that a web designer could still
> screw up the display logic.... hmmm...

leads me to believe that you're not so sure about this :)

See http://en.wikipedia.org/wiki/Business_logic for further discussion
on the matter. Or just search google for terms like MVC or
multi-tier-architecture.

Regarding using Smarty as your implementation, personally, I think it's great.
I know there are other great solutions out there so it really depends
on your requirements.

Keep in mind that Smarty actually does more than just separate
business from presentation. For example, It has some very nice caching
features.

See http://smarty.php.net/rightforme.php and
http://smarty.php.net/whyuse.php for more info.

When considering what software package / solution to use for any given
task, I like to use the analogy of buying a car. There is no single
car that's "best" or right for everyone. There are plenty factors you
need to take into account when deciding what to get, but at the end of
the day, there will be many solutions that will meet your needs.

Hope that helped
- Ophir


On 9/4/06, LeeEyerman at aol.com <LeeEyerman at aol.com> wrote:
>
> TO SMARTY OR NOT TO SMARTY: THAT IS THE QUESTION
>
> A client of mine is debating, rather furiously, the merits of using Smarty
> in their upcoming web-applications.  Up to this point, I have not used
> Smarty - and I will admit it - I am an old school programmer who hates OOP,
> and to me, Smarty looks like another ill-conceived paradigm developed in OOP
> that creates a lot more hassle than it solves.
>
> We are a small organization.  We do not have more than two PHP developers
> working on a project at a time.  Our designer works closely with us to
> integrate CSS, Javascript, etc.  The web sites we create are for government
> agencies and do not change often, and if they do change, they do not change
> very much.
>
> I understand the concept behind smarty - separate logic and display.
> However, I do not think Smarty is an end-all solution to all web sites - as
> many people are trying to sell it.  This article, Smarty for Dummies, shares
> many of the thoughts and opinions I have about Smarty:
> http://www.fudnik.com/main/tiki-read_article.php?articleId=7
> - it is a good read.
>
> Can anyone give any guidance about when to and when not to use Smarty?  Does
> anyone agree/disagree that Smarty may just be a giant abstraction of logic
> and design, wrapped in a horrible OOP mess?  Does anyone agree/disagree that
> using Smarty in small applications, that do not change much, and do not have
> separate (or large) development teams may be more burdensome than it is
> worth?  Is anyone concerned that using Smarty as part of your systems make
> them less portable?  Am I missing something, or is Smarty just not meant to
> be used in small development environments?
>
> I do not like the idea of developing web apps using Smarty because of the
> additional requirements of installing smarty.  I am also concerned that
> Smarty may be built upon technologies that may be part of a current patent
> or part of a patent that is pending.  Smarty is not that old, and it could
> potentially infringe a patent by another company like MS.   I also do not
> know if Smarty is supported in the open-source community as well as PHP and
> MySQL.
>
> I also cannot stand the editing of multiple documents, both containing bits
> and pieces of logic - I know, one is application logic, the other is display
> logic.... is this really logical?  Bouncing between documents does not seem
> efficient, and it also seems quite possible that a web designer could still
> screw up the display logic.... hmmm...
>
> Whether you would still call Smarty a new paradigm is up for question.
> However, I am having a hard time understanding any benefit for small
> sites/organization who need to deliver SOLID solutions fast, on-time, and
> within budget.  Can anyone tell me how Smarty can increase productivity?
> Can it save time?  Can it save money?  Does it make your web-app any more
> secure? Doesn't it actually make your applications slower - all that code to
> process - and I know, it does the pre-processing - but still, OOP requires
> more code that procedural any day - and looking at Smarty code, it looks
> like a OOP mess.
>
> Like OOP, I can do everything Smarty does, faster and easier in procedural
> PHP on one page.  Why in the world would I change to Smarty?
>
> It is also interesting to note that very few open-source applications use
> Smarty.  PHPBB does not use it, OSCommerce does not use it, PHPMyAdmin does
> not use it, etc.  If Smarty were so good, why haven't more open-source
> projects adopted it?
>
> Any information that could assist my reasoning, one way or the other, would
> be greatly appreciated!
>
> Thank you in advance!
> Lee
>
>
>
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
>


-- 
Ophir Prusak
http://www.prusak.com



More information about the talk mailing list