Keeping code and design apart?
Moderator: General Moderators
Keeping code and design apart?
Hi!
I've heard alot of people talking about keeping PHP and HTML apart, in different files and so on. I see the logic in this statement, but how do you keep it apart? I've heard something about templates, but I can't figure it out. And are there any other methods of doing so?
I've heard alot of people talking about keeping PHP and HTML apart, in different files and so on. I see the logic in this statement, but how do you keep it apart? I've heard something about templates, but I can't figure it out. And are there any other methods of doing so?
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
The whole thing is to keep the Model, the View and the Controller separated...
You can get more info on MVC (applyed on J2EE) at
http://java.sun.com/blueprints/patterns ... ailed.html
I developped a FrameWork that tries to bring the MVC concept to PHP.
Isn't released yet, cause I don't get to the time to setup CVS on sf.net and code a small demo app, but I can give you the sources already if you are interested and guide you on it...
I already posted on that at:
viewtopic.php?t=11789&start=0&postdays= ... highlight=
You can get more info on MVC (applyed on J2EE) at
http://java.sun.com/blueprints/patterns ... ailed.html
I developped a FrameWork that tries to bring the MVC concept to PHP.
Isn't released yet, cause I don't get to the time to setup CVS on sf.net and code a small demo app, but I can give you the sources already if you are interested and guide you on it...
I already posted on that at:
viewtopic.php?t=11789&start=0&postdays= ... highlight=
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
Well I might be saying this is the most efficient way.
I shall here not argue OO vs. Procedural
I've made my choice. While it took me years to understand the advantages OO has over procedural...
But I am convienced now!
And patterns are high on that list, MVC bieng one of the most important ones imho
I shall here not argue OO vs. Procedural
I've made my choice. While it took me years to understand the advantages OO has over procedural...
But I am convienced now!
And patterns are high on that list, MVC bieng one of the most important ones imho
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
I didn't say it isn't done (well it was not as I wrote those other posts)
But I believe the FrameWork is already useful. I use it on different projects already.
It isn't perfect though and I need pretty much feedback from other users and probably I'll change a few things to it.
In the meantime I am in the process of releasing it on sourceforge (right now).
But as I mentionned you can get the source already if you want. Just CVS will be up as soon as sf.net has accepted the project...
But I believe the FrameWork is already useful. I use it on different projects already.
It isn't perfect though and I need pretty much feedback from other users and probably I'll change a few things to it.
In the meantime I am in the process of releasing it on sourceforge (right now).
But as I mentionned you can get the source already if you want. Just CVS will be up as soon as sf.net has accepted the project...
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
Argh... Windows!
I already got your first bug report :

I'm setting up a quick tarball you'll have to work you way through it...
It is available at http://lily.itresolved.org now
There is no demo app right now... And I won't have time to code it before tomorrow or so. There is a small demo vhost config for apache, you might want to look at, uses rewrite rules for i18n.
You'll have to hack yourself through the code... You can fall back on me anytime. Now that you got it, I'm waiting for remarks, bugs, help... all you think is constructiv
!
I already got your first bug report :
Just that you knowWTF aren't you using DIRECTORY_SEPARATOR
I'm setting up a quick tarball you'll have to work you way through it...
It is available at http://lily.itresolved.org now
There is no demo app right now... And I won't have time to code it before tomorrow or so. There is a small demo vhost config for apache, you might want to look at, uses rewrite rules for i18n.
You'll have to hack yourself through the code... You can fall back on me anytime. Now that you got it, I'm waiting for remarks, bugs, help... all you think is constructiv
Be careful with MVC in web apps. The idea of a single controller managing the workflow as well as a model and view (actually there could be several) is both confused and confusing.
Last edited by McGruff on Thu Feb 12, 2004 12:36 pm, edited 1 time in total.
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
That's just my take - others might disagree. And this isn't a comment on your code which I haven't seen.greenhorn666 wrote:I don't see what is confused about the MVC pattern... even applyed to web application; while I admit that this can get confusing.
Thanks
I've got no problem with model & view but alarm bells start ringing when I see how the controller is normally conceived.
In a web app, there needs to be some kind of workflow manager. This might load various objects to carry out pre client-output tasks, print the client output, and finally various post client-output tasks.
Pre and post client-ouput tasks could be silent or they could be "print"-type operations eg email notification, writing log files etc - anything which is read by someone. There could be more than one model and view to manage.
It would seem to drive a coach and horses through the principle of RDD to have a single controller responsible for all that: ie workflow and various unrelated models & views. If the app isn't very complex, design flaws can be concealed - but might not be when you try building on it.
I think it's important to distinguish between workflow management and the various print operations. Print managers (Email, ClientPage etc) could be assigned responsibility for loading a model & view and printing the item. There would be a separate printer object for each print task, each managing a single model and view. In that way MVC is embedded in apps, not entire apps in MVC.
I find it helpful to use a PrintManager interface which encapsulates the model-view separation.
Code: Select all
<?php
class Printmanager
{
function loadModel()
{
die('Method not implemented<br />.' . __LINE__ . ' | ' . __FILE__);
}
function loadView()
{
die('Method not implemented<br />.' . __LINE__ . ' | ' . __FILE__);
}
function printPage()
{
die('Method not implemented<br />.' . __LINE__ . ' | ' . __FILE__);
}
}
?>
Last edited by McGruff on Tue Aug 09, 2005 6:34 pm, edited 1 time in total.
- greenhorn666
- Forum Commoner
- Posts: 87
- Joined: Thu Aug 14, 2003 7:14 am
- Location: Brussels, Belgium
My code is now online on sf.net with a demo app.
http://lily.itresolved.org
Just go and see for yourself, I am more than open to remarks, since I want to have it as useful for anyone as possible...
Thanks
http://lily.itresolved.org
Just go and see for yourself, I am more than open to remarks, since I want to have it as useful for anyone as possible...
Thanks