|
Posted by Henk verhoeven on 05/08/07 22:03
alvarojaviervera@gmail.com wrote:
> Im programer (about 2 years ago I started), and allways I use PEAR.
> and Now I was thinking about change my tool for building custom
> dynamic sites.
> What do you think sholud be better Smarty, may be Pear or another one?
Hi Alvaro,
You could try the Composition by inclusion and callback pattern, see
http://www.phppeanuts.org/site/index_php/Pagina/195
> Why?
- Makes it easy to build and reuse your own page component classes
- simpelest thing that could possibly work to get strong separation of
layout and php code
- Flexibilty of php available in the include files (must have some
discipline though not to mess up the separation of layout and code).
> I need your comments and experience.
I first used it to build pntUnit unit testing tool, which worked to get
the separation of layout and code. Also worked to group user interface
related functions into classes. Then i did the same with a content
managed website.
Later when i built the phpPeanuts framework i used it in combination
with a front controller so i could change the page or component class
without changing the referring url or include call. That makes it much
easyer to delay decisions about specialization until the need really is
manifest.
At first i combined it with a DOM (representing the layout itself in
objects) for finegrained components, like rows and cells in tables, but
that resulted in code that was much harder to read and understand than
the code resulting from following the "composition by inclusion and
callback" pattern. So in the end i refactored the components that used
the DOM. To speed up the inclusion of fine grained reoccuring elements i
added an event handler technique to the table component.
I have been using both the framework and the "composition by inclusion
and callback" pattern for several years and see only one reason to
rethink it: AJAX. Probably the pattern will only have to be extendend by
an AJAX-based inclusion mechanism, but i have not yet tested that theory.
Greetings,
Henk Verhoeven,
www.phpPeanuts.org.
Navigation:
[Reply to this message]
|