The current discussion about whether or not to use Smarty nowadays misses the point as it may simply depend on the environment. In a small development team, up to five people or so, you could just use the template-alike PHP syntax as all parts of the application are written by the same people with more or less equally shared responsibilities. This is what I would call a “single hands” process. Everything is done by everyone (that’s a bit oversimplified as in such environments intuitive structures emerging but let’s take it for now). This kind oft environment can often be found in startups and the like. This is were the process is really hands-on, the development process is often relatively agile as everyone is the others neighbour and there is often no explicit design stage. This is were you just ask your mate “hey, what’s the name of this template variable”. Such an environment has a lot of advantages but for sure a lot of disadvantages, often in terms of quality.
In other environments where responsibilities are much finer grained and balanced, a template engine might become a structural element of the development process as it represents a responsibility split between collegues. A template language is in fact an API for the user interaction/frontend developer. An API is a small subset of the factual possibilities, and this is where a template language might represents organisation prinicples. We as software developers define our API to encapsulate richer functionality and provide access to a well-thought (yeah, hopefully) subset of modification paths we want to allow on purpose. Just because the other guy does not need to know about the ugly internals. A good template language is a small subset of the language environment and exposes only functions which are really needed for view generation.
Beneath that, a template engine can structure the adoption of a pattern. Think about the MVC pattern, which is nowadays halfway common in web development environments. A template language in an MVC-alike environment enforces the usage of the view as “just a view”. While you would need to establish rules and procedures which subset of PHP is allowed correct for templating, a template engine establishs this rules and procedures implicitly. The other side of “do not try to solve social problems technically” is “do not try to solve technical problems socially”.
I concede that the relational model is the worst form of DBMS except for all those other forms that have been tried from time to time.
Bill Karvin – In Support of the Relational Model
I can’t agree more with that statement. Also I find software like CouchDb really interesting, it will not be the way to go. Beneath modeling, the main advantage of relational models is the flexible question startpoint (in terms of SQL it means the basic information you have beforehand to get the rest of what you need). If you know just a little about tree structure, the start point problem will be self-explaining. Accessing an upper node from a sub node just can’t be implemented as fast as accessing a flat structure and there relations.
I want to provide you a pattern I which I thought about a lot in the last days. Comments are appreciated.
$image1 = new ImageBinary(array(‘id’ => 1));
$image2 = new ImageBinary(array(‘id’ => 2));
$image3 = new ImageBinary(array(‘id’ => 3));
$worker = new ImageWorker;
... und erst ihr Code:
/* WAS IST DAS ??? //ich weiss es auchnicht aber es ist schon lange auskommentiert glaube ich $db->Execute("UPDATE weblogs SET title='$_POST[blog_title]', info='$_POST[blog_desc]',name='$_POST[blog_name]',template='$_POST[blog_template]' WHERE id = ".$_SESSION['weblog']['id']); $db->Execute("UPDATE weblogs SET aktiv='$_POST[blog_aktiv]' WHERE id = ".$_SESSION['weblog']['id']); */