I'm having some trouble deciding how to structure the flow of my application. I have objects that handle the UI (View) and objects that handle the database interaction and business logic (Model).
I'd like to move to a more OO design for the actual pages of the site (controllers), but I tend to lean toward a procedural design in this area.
I've used Ruby on Rails and built a simple base controller class in PHP to handle actions like rails does, but I think i'd rather stick to the traditional PHP structure and implement some OO techniques along the way. I've read on the forum people calling this method POOP (procedural-OO-procedural).
Is this a bad habit to get into or bad [-removed design-] implementation?
Program Flow, POOP? (procedural-OO-procedural)
Moderator: General Moderators
Program Flow, POOP? (procedural-OO-procedural)
Last edited by phpMitch on Tue Oct 24, 2006 6:32 pm, edited 1 time in total.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Program Flow, POOP? (procedural-OO-procedural)
I think you mean "implementation" not "design" here.phpMitch wrote:I'd like to move to a more OO design for the actual pages of the site (controllers), but I tend to lean toward a procedural design in this area.
Ok ... now I'm confused. I am not clear how "top down design" (or bottom up for that matter) has much to do with procedural vs OO?phpMitch wrote:I've used Ruby on Rails and built a simple base controller class in PHP to handle actions like rails does, but I'd rather stick to the old top down design using objects along the way.
(#10850)
Sorry, if you have used web frameworks like Rails (or the many implementations of it in PHP), they all seem to have the individual scripts (for example login.php) set up like a class where each action (say login, logout) is a method of that class.
I'm used to setting it up these pages in what I would think is more procedure-oriented.
For example:
Now I do use objects to handle the processing of things like logging in/out, registration and displaying the view. I'm just not sure I like the make everything a class theory.
I'm interested to see how others are writing their applications, and what the best practices are.
I'm used to setting it up these pages in what I would think is more procedure-oriented.
For example:
Code: Select all
[Start pseudo code]
Include configs, and other app wide files here.
If user Posted login form
{
do login stuff
}
If user Requested Logout
{
do logout stuff here
}
Display view
[/end pseudo code]I'm interested to see how others are writing their applications, and what the best practices are.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I'm still trying to get to the bottom of your application design. I think maybe your struggle is between Page Controllers and Front Controller + Action Controllers. The latter would probably be considered the most common direction these days. An Action Controller does what a traditional PHP script does in many ways -- it just adds structure to loading and initialization.
(#10850)