template inheritance

A

Alex K

While building a website using template inheritance one usually does
the following:

fetch from database
fetch from some more data from database
.... << more required computations
then at the end render the template with the fetched data

Without template inheritance one usually does the following:

fetch from database
render this part of the site with this fetched data
fetch some more data from the database
render this other part of the site with the fetched data
....
etc

The first approach is much more elegant and leads to easier to
maintain code. However the user will have to wait till the end of the
fetching (long computations) before any rendering can take place. In
the second approach however the site loads as we are fetching the data
which is more convenient to the user.

Am I correct to assume this? Is there a way to get the best of both
worlds? Thank you.
 
D

Diez B. Roggisch

Alex said:
While building a website using template inheritance one usually does
the following:

fetch from database
fetch from some more data from database
... << more required computations
then at the end render the template with the fetched data

Without template inheritance one usually does the following:

fetch from database
render this part of the site with this fetched data
fetch some more data from the database
render this other part of the site with the fetched data
...
etc

The first approach is much more elegant and leads to easier to
maintain code. However the user will have to wait till the end of the
fetching (long computations) before any rendering can take place. In
the second approach however the site loads as we are fetching the data
which is more convenient to the user.

Am I correct to assume this? Is there a way to get the best of both
worlds? Thank you.

I don't think that the question of inheritance or not is really relevant
here.

It's a matter of how the templating system is written - does it collect
all the data beforehand, or not, is it potentially using e.g. generators
and so forth.

And of course how the programmer uses the templating system. does he
fetch all the data beforehand, or does he use lazy generation approachs
- again, e.g. generators, or callbacks.

Besides, *usually* the 20-39Kb of a website itself aren't the problem
I'd say - loading referenced resources is much more of an issue.

And AFAIK the render-mode matters, too. If the site is XHTML-compliant,
the browser can start the rendering once the HTML is complete -
otherwise, it might wait until the referenced resources are all loaded
to calculate the layout.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top