Page 1 of 1

Program Flow, POOP? (procedural-OO-procedural)

Posted: Tue Oct 24, 2006 2:29 pm
by phpMitch
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?

Posted: Tue Oct 24, 2006 2:34 pm
by Luke
POOP... haha

almost as good as ffart.

Re: Program Flow, POOP? (procedural-OO-procedural)

Posted: Tue Oct 24, 2006 2:38 pm
by Christopher
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.
I think you mean "implementation" not "design" here.
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.
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?

Posted: Tue Oct 24, 2006 2:53 pm
by phpMitch
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:

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]
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.

Posted: Tue Oct 24, 2006 3:22 pm
by Christopher
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.