Re-use of user interface parts, separation of design and code

This is a discussion on Re-use of user interface parts, separation of design and code within the PHP Language forums, part of the PHP Programming Forums category; Hello everyone, I've posted this question before, but got no answer, so I'll try to reformulate the question, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-11-2003
Eric Veltman
 
Posts: n/a
Default Re-use of user interface parts, separation of design and code

Hello everyone,

I've posted this question before, but got no answer,
so I'll try to reformulate the question, maybe it helps :-)
By the way, this is not intended as the start of an ASP.NET flamewar.

Before looking at PHP, I've used ASP.NET extensively for
about a year and some things that I like a lot about it :

- Design and code can be easily kept separate.
For pages, the HTML tags and tags that represent web controls,
user controls and custom controls are put in an .aspx file,
the code is kept in an .aspx.cs file, which contains handlers
for the events that are emitted by the controls.
For user controls, design is kept in an .ascx file,
code is kept in an .ascx.cs file.

- Pieces of user interface can be easily re-used.
You can easily make user interface components that
combine existing web controls. Examples are a
menu pane, location bar, navigation bar, etc.

- Very much OO and event-oriented ( is that 4-GL ? )
Everything that you program against is an object.
The .aspx or .ascx with tags is parsed and a server side
control tree is created. Saved state information is passed
to the controls in the tree, post information is passed to
the controls. This way, the controls can emit change events
and click events, so you don't have to "parse" post information
yourself, the controls do that.

These are, I guess, the most important ones.
From what I've seen from PHP, the barebones PHP is more or less
equivalent to old-fashioned ASP, but lots of components exist
to separate code from design and to work with more object orientation.

So now my question ... What approaches and components
do you people use to enable re-use of user interface parts
and keep design and code separate ?

Best regards,

Eric
Reply With Quote
  #2 (permalink)  
Old 10-11-2003
rush
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

"Eric Veltman" <eric@[RemoveThis]veltman.nu> wrote in message
news:vofl3rbms24h4e@corp.supernews.com...
> So now my question ... What approaches and components
> do you people use to enable re-use of user interface parts
> and keep design and code separate ?


Okey dokey, here is how would you do it with help of TemplateTamer.

First for separation of design and code, TT will kep them in separate files.

If your page is named for instance "hello", html template for that page will
be "hello.html" and it will reside in "html/" directory.

The code you write will reside in the file named "hello.logic.php" and it
will reside in "logic/" directory. Your responsibility is to define class
"Hello_page" in this file which will define how this page is about to
behave.

The TT will generate "hello.php" file which will do all hard chores related
to the template, like loading all necessary stuff, including your
..logic.php, instantiating Hello_page class, do all necessary transformations
on the template end output the result.

In your app you will generally come up with small hierarchy of classes for
your pages. Typically one root class that handles stuff common for all pages
on your site (like menu, sessions, translation to different languages,
etc..). Classes below would ad specific behaviour for each page.

As for components or widgets there is less support, but you can create them
for use in the project by defining template as a global, and by writing a
class that drives it. Then for reuse, you put <!--USEGLOBAL:GLBNAME --> in
your html, and in code you write something like:

....
$glb = new GlbComponent();
$page['GLBNAME'] = $glb->getData();
....

What is probably less developed at the moment is interchange of such
components between different projects and developers.

Hope that answers some of your questions.

rush
--
http://www.templatetamer.com/



Reply With Quote
  #3 (permalink)  
Old 10-11-2003
Martin Wickman
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

In article <vofl3rbms24h4e@corp.supernews.com>, Eric Veltman wrote:

> Before looking at PHP, I've used ASP.NET extensively for
> about a year and some things that I like a lot about it :


[...]

> These are, I guess, the most important ones.
> From what I've seen from PHP, the barebones PHP is more or less
> equivalent to old-fashioned ASP,


The main difference is that MS forces their way of doing things, that
is, with events and aspx etc. Personally, I can't deal with their
overly complex template structure. But some people apparently like it.

The points is that php can (of course) do all those things as well,
but it leaves the choices to the developer. It does not try to stuff
anything down your throat.

Take a look at http://smarty.php.net/ if you want a template engine.

My personal experience is that one should not try too hard to separate
code from design in a web environment, its not worth the effort.
Reply With Quote
  #4 (permalink)  
Old 10-11-2003
Tony Marston
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code


"Martin Wickman" <wizball@hotbrev.com> wrote in message
news:slrnbogdvn.ek4.wizball@babar.tuffmusik.nu...
> In article <vofl3rbms24h4e@corp.supernews.com>, Eric Veltman wrote:
>
> > Before looking at PHP, I've used ASP.NET extensively for
> > about a year and some things that I like a lot about it :

>
> [...]
>
> > These are, I guess, the most important ones.
> > From what I've seen from PHP, the barebones PHP is more or less
> > equivalent to old-fashioned ASP,

>
> The main difference is that MS forces their way of doing things, that
> is, with events and aspx etc. Personally, I can't deal with their
> overly complex template structure. But some people apparently like it.
>
> The points is that php can (of course) do all those things as well,
> but it leaves the choices to the developer. It does not try to stuff
> anything down your throat.
>
> Take a look at http://smarty.php.net/ if you want a template engine.
>
> My personal experience is that one should not try too hard to separate
> code from design in a web environment, its not worth the effort.


I strongly beg to differ. In the 3 tier architecture one strives to separate
the presentation layer (user interface) from the business layer and the data
layer. In a web environment that means that you do not have a single
component which generates HTML, processes business rules and communicates
directly with the database. I have created a development environment around
the 3 tier architecture (refer to
http://www.tonymarston.net/php-mysql...structure.html) in which the
business layer is PHP but the presentation layer is XML/XSL and CSS which
results in XHTML 1.0 Strict. This makes maximum use of template engines
which are controlled by open standards (supervised by the World Wide Web
Consortium) and not small-time proprietary standards written specifically
for PHP.

The advantage is that I can produce web applications where the presentation
layer can be customised and modified without ever touching any code in the
business layer. All it needs is knowledge of HTML, CSS, XML and XSL which
should be the standard tools of any web developer.

Just my personal opinion.

Tony Marston
http://www.tonymarston.net/


Reply With Quote
  #5 (permalink)  
Old 10-13-2003
Lothar Scholz
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

> http://www.tonymarston.net/php-mysql...structure.html) in which the
> business layer is PHP but the presentation layer is XML/XSL and CSS which
> results in XHTML 1.0 Strict. This makes maximum use of template engines
> which are controlled by open standards (supervised by the World Wide Web
> Consortium) and not small-time proprietary standards written specifically
> for PHP.


I think he was talking about economical reasons and here it is not
necessary to use open standarts - you must get your work done.

And i've never seen any good reason to use XSL other then getting some
more money from customers by using buzzwords.
Reply With Quote
  #6 (permalink)  
Old 10-13-2003
Eric Veltman
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

Eric Veltman wrote:

> These are, I guess, the most important ones.
> From what I've seen from PHP, the barebones PHP is more or less
> equivalent to old-fashioned ASP, but lots of components exist
> to separate code from design and to work with more object orientation.
>
> So now my question ... What approaches and components
> do you people use to enable re-use of user interface parts
> and keep design and code separate ?


Thank you Martin, Tony, Lothar and rush for the suggestions.
I think I'll take a look at Smarty first as that seems to
be the most popular framework.

Best regards,

Eric



Reply With Quote
  #7 (permalink)  
Old 10-14-2003
lawrence
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

Martin Wickman <wizball@hotbrev.com> wrote in message
> The main difference is that MS forces their way of doing things, that
> is, with events and aspx etc. Personally, I can't deal with their
> overly complex template structure. But some people apparently like it.
>
> The points is that php can (of course) do all those things as well,
> but it leaves the choices to the developer. It does not try to stuff
> anything down your throat.
>
> Take a look at http://smarty.php.net/ if you want a template engine.
>
> My personal experience is that one should not try too hard to separate
> code from design in a web environment, its not worth the effort.


This is an attitude that one can afford only if one works alone. I'm
aware of it because I've only recently made the transition from
working alone to working with others. I started writing a CMS 2 years
ago and recently some friends and I decided to start a business around
it. Now I have to work with graphic designers who don't know anything
about PHP. First of all, that makes me grateful that I'd already
separated presentation from logic. Second of all, that forced me to
introduce a template system, sort of like what they use with
MoveableType.

Microsoft might push a method, but all the template frameworks push a
method. As soon as you sign up for any framework, your signing up for
the rigidity of that framework, which isn't necessarily a bad thing.
On the negative side, any framework will limit your range of action
somewhat. On the bright side, using a framework means someone else has
thought about the tough issues and you can avoid getting burned if you
just follow the framework.
Reply With Quote
  #8 (permalink)  
Old 10-14-2003
Martin Wickman
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

In article <bm9sm6$gch$1$8300dec7@news.demon.co.uk>, Tony Marston wrote:
> "Martin Wickman" <wizball@hotbrev.com> wrote in message


[..]

>> The main difference is that MS forces their way of doing things,
>> that is, with events and aspx etc. Personally, I can't deal with
>> their overly complex template structure. But some people apparently
>> like it.
>>
>> The points is that php can (of course) do all those things as well,
>> but it leaves the choices to the developer. It does not try to
>> stuff anything down your throat.
>>
>> My personal experience is that one should not try too hard to
>> separate code from design in a web environment, its not worth the
>> effort.

>
> I strongly beg to differ. In the 3 tier architecture one strives to separate
> the presentation layer (user interface) from the business layer and the data
> layer.


Yes, that is nice and, as I said, I dont oppose that. Problem is that
most people goes to far with this content/logic/oo stuff. Aim to
separate design from content in a webb environment, but dont be afraid
to cheat or you'll never be finished.
Reply With Quote
  #9 (permalink)  
Old 10-14-2003
Martin Wickman
 
Posts: n/a
Default Re: Re-use of user interface parts, separation of design and code

In article <da7e68e8.0310132257.75a03637@posting.google.com >, lawrence wrote:
> Martin Wickman <wizball@hotbrev.com> wrote in message
>> The main difference is that MS forces their way of doing things, that
>> is, with events and aspx etc. Personally, I can't deal with their
>> overly complex template structure. But some people apparently like it.
>>
>> The points is that php can (of course) do all those things as well,
>> but it leaves the choices to the developer. It does not try to stuff
>> anything down your throat.
>>
>> Take a look at http://smarty.php.net/ if you want a template engine.
>>
>> My personal experience is that one should not try too hard to separate
>> code from design in a web environment, its not worth the effort.

>
> This is an attitude that one can afford only if one works alone.


Is it? I've been in this (silly) business from day one and I have yet
to see a working solution. The only thing that matters is that you get
the work done on time and budget and that the solution is easy to
understand.

<rant>

After all, creating a webb application is not really rocket-science
these days. In fact, it is not hard at all. Ever since rfc1946 have
people tried to add more and more unnecessery complexities to
something that is _not_ complex at all. And that is of course just
stupid.

I sometimes believes the real reason for people who does that, is that
they need to make the easy solution complex and hard, so that they can
justify themselves when arguing with the people who does the real work
and do not spend time throwing the latest buzzwords around.

I'm thinking mostly java and java.apace.org here. But the latest .NET
stuff is pretty close.

Now, go do some real work. Hack a new kernelfs or php-extension or
something. :-)

</rant>

> Microsoft might push a method, but all the template frameworks push
> a method.


Yes, but PHP alone does not push any method at all, and that is what I
said above.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0