Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Three layer application

     

optik

6:58 pm on Apr 16, 2010 (gmt 0)

5+ Year Member



I'm trying to build a site using the 3 layer concept of data, application and presentation but I'm getting confused in the detail.

When there is a lot of dynamic content the application layer will be generating data for the presentation layer depending on the input from a user.

So for instance a search page result may have 4 results or 10. Usually I would loop the array fetched from SQL and the html would be added to in each loop cycle with the correct data either by a direct echo or appending a variable to be echo later in the program.

This of course means that there is html code in the application layer.

There seems no way around this as I have to produce 4 blocks of html sometimes 10 blocks of html and so on.

Is this concept just a myth or am I missing something?

FourDegreez

4:56 pm on Apr 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is your design object-oriented? If you use simple data objects to represent the data in the rows, you would load the data into those objects and pass the objects to the presentation layer. Here you would loop through the objects and mix their data fields in with the HTML code.

optik

11:11 am on Apr 18, 2010 (gmt 0)

5+ Year Member



Won't that result in more code though slowing the app down, I can see the point when a lot of pre-formatting of the data has to occur but say you just wanted to retrieve a short list from a database and present that accordingly with no data formatting then would this be over doing it?

optik

11:28 am on Apr 18, 2010 (gmt 0)

5+ Year Member



Another thing is a lot of page elements rely on conditionals depending on the data, they would still have to remain on the presentation page

Leaving the presentation page full of loops and conditionals and only really removing the database call.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month