Page 1 of 1
Converting a templating system to OOP
Posted: Wed Apr 20, 2005 9:55 am
by vigge89
I'm thinking about converting my current project - a cms with an inbuilt templating system and parser - to OOP. The idea I'm having is to make page-handling (loading a page, managing variables and templates, etc.) into a class (maybe a static one?), with an parser-class (parses the templates, changing output based on contents of $page->variables, etc.) which extends it. The question is, is this a good idea? I think handling and extending the page-class with different things (for example the parser) would be a lot easier, but I want your ideas on this. I'm storing the templates in a database, and have the different functions in php-files.
I'm interested in your ideas, do you think it's good, do you have any other idea on how to design the cms, have you developed your own cms and got hints or tips? Everything is appreciated
Thanks //vigge
Posted: Wed Apr 20, 2005 10:13 am
by patrikG
Posted: Thu Apr 21, 2005 1:18 pm
by magicrobotmonkey
depending how far along you are, you might want to think about scrapping rather than converting. You don't want your current code to limit the strength of your new code.
Posted: Thu Apr 21, 2005 2:57 pm
by Roja
magicrobotmonkey wrote:depending how far along you are, you might want to think about scrapping rather than converting. You don't want your current code to limit the strength of your new code.
"It's important to remember that when you start from scratch there is absolutely no reason to believe that you are going to do a better job than you did the first time"
http://www.joelonsoftware.com/articles/ ... 00069.html
Posted: Sat Apr 23, 2005 12:20 pm
by magicrobotmonkey
yea that's why i said "depending how far along you are." plus its his own code, so some of the stuff from that article doesn't apply. It does make some good points though.
Posted: Sat Apr 23, 2005 2:29 pm
by McGruff
It's a good idea to keep classes nice and tight, each doing just one thing.
For a Foo view, I'd probably have a FooViewData object (which gathers data for the Foo view from domain objects - or direct from the data acess layer if there's no domain logic to do) and output strategies: FooViewHtmlPrinter, FooViewCommandLinePrinter, and so on.
Posted: Mon Jul 25, 2005 8:02 am
by fastfingertips
Hm better scrapping
Imagine for example that even application design is different in PHP5. Now using class types like abstract and interface (and not only) you can create and implement a stronger structure.