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

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
phpMitch
Forum Newbie
Posts: 2
Joined: Tue Oct 24, 2006 2:09 pm

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

Post 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?
Last edited by phpMitch on Tue Oct 24, 2006 6:32 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

POOP... haha

almost as good as ffart.
Last edited by Luke on Tue Oct 24, 2006 2:42 pm, edited 1 time in total.
User avatar
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)

Post 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?
(#10850)
phpMitch
Forum Newbie
Posts: 2
Joined: Tue Oct 24, 2006 2:09 pm

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
Post Reply