Page 1 of 1

Perfection and code readability

Posted: Wed Jan 29, 2003 1:42 pm
by Heavy
I decided to check out phpBB under the hood.

Now, I am Amazed about how cleanly it is written. I always wondered why my own projects end up looking bloated...

I guess the greatest reason to that is that I use to output HTML with PHP in the same php-file where the server automation is performed.

Well, phpBB (including this forum) is not. phpBB is class oriented and the actual presentation is done like this:

Code: Select all

<?php

//blablabla

//
// Generate the page
//
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

//blablabla

?>
... 8O ...

So... They are actually parsing a template using PHP... 8O

That is so rigid, it must have taken much effort to design the model from wich they worked it out.

Code is separate from design.
Automation is never bloated with HTML rubbish.


What about performance?

The PHP files can be cached using PHP Accelerator, but are the template files cached in any way? I guess not. People always tell me it is faster to query a DB for some text than opening a file and retrieving the data from there. :? Maybe I should do some benchmarking myself before saying it is so...

I guess templates can be read once and inserted into the DB with a special admin "scan for templates" command and thus increasing performance.

I don't have a well defined question about this, but I would like to start a thread about perfection of php usage.

Posted: Wed Jan 29, 2003 1:59 pm
by evilcoder
I'm working on an OO Authentication Gateway at the moment, and without classes and functions, it would be a nightmare.

I guess the thing you have to weigh up is:

Do you want to writing the same piece of code over and over?

Thats why OOP makes things easier, it prevents you from having to do that. for example you can make a class for database connection and use it on as many databases as you like. But all the values assigned to it can be changed by making a new instance of the original class.

As for performance, you have to justify using OOP. I can because i use alot of the same code, over, and over again.

Posted: Thu Jan 30, 2003 2:30 am
by Heavy
I know there are great books to read about OOP.
Anyone that knows of a guide, howto, lesson or tutorial on the Internet that discusses OO implementation in a web-application (preferrably utilizing PHP)?

Posted: Thu Jan 30, 2003 2:34 am
by evilcoder
http://www.spoono.com/tutorials/php/aoo/

Great tutorial on OO and Classes.

Posted: Thu Jan 30, 2003 3:44 am
by Heavy
Thanks. It looked pretty good. But I discovered an error in the example of dummy4 and dummy5. I posted a comment about it, so it might be fixed if you try to find the error too.

Posted: Thu Jan 30, 2003 4:28 am
by evilcoder
i didnt learn from there, i just learnt by myself. Just had that in my link favourites. :)

Posted: Thu Jan 30, 2003 4:33 am
by Heavy
Dont go there
I checked out one more example about alternating row colors, and even that one had significant errors... :evil: