473,507 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
8 2579
"Eric Veltman" <eric@[RemoveThis]veltman.nu> wrote in message
news:vo************@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/

Jul 17 '05 #2
In article <vo************@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.
Jul 17 '05 #3

"Martin Wickman" <wi*****@hotbrev.com> wrote in message
news:sl********************@babar.tuffmusik.nu...
In article <vo************@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/
Jul 17 '05 #4
> 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.
Jul 17 '05 #5
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

Jul 17 '05 #6
Martin Wickman <wi*****@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.
Jul 17 '05 #7
In article <bm*******************@news.demon.co.uk>, Tony Marston wrote:
"Martin Wickman" <wi*****@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.
Jul 17 '05 #8
In article <da**************************@posting.google.com >, lawrence wrote:
Martin Wickman <wi*****@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.
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6409
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
11
3987
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
2
106586
by: sky2070 | last post by:
i have two file with jobapp.html calling jobapp_action.php <HTML> <!-- jobapp.html --> <BODY> <H1>Phop's Bicycles Job Application</H1> <P>Are you looking for an exciting career in the world of...
2
5268
by: JW | last post by:
I wanted have this as part of a flood control script: <? echo ("Flood control in place - please wait " . $floodinterval . " seconds between postings."); sleep(5); // go back two pages echo...
6
3501
by: Chris Krasnichuk | last post by:
Hello every one, Does anyone know how to make php work on your computer? please reply I need help Chris
2
3327
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd...
3
5368
by: Dell Sala | last post by:
I have recently enabled the PHP 4.2.1 that comes pre-installed on OS X. After making all the prescribed changes to the httpd.conf file php seems to work fine. I would like to make some changes...
20
11624
by: bb | last post by:
I'm not a Perl programmer nor a Linux adherent. What are the advantages of LAMP vs.the Java model for building data-driven websites? I do a fair amount of development using Tomcat/JSP/Servlets...
1
108820
by: lawrence | last post by:
I just switched error_reporting to ALL so I could debug my site. I got a huge page full of errors. One of the most common was that in my arrays I'm using undefined offsets and indexes. These still...
2
3862
by: poff | last post by:
I have written a forum and am using the following query to search in it: $query="select topics.tid,f_messages.messid from f_messages left join topics on f_messages.tid = topics.tid where...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.