By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,379 Members | 3,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,379 IT Pros & Developers. It's quick & easy.

MVC/OO pattern clarification

P: n/a
Greetings All,

I had a question about OO implementation in the MVC pattern that is
directed at anyone who feels experienced with it.

My fuzziness comes from trying to learn OOP and MVC at the same time,
coming from a procedural background where I used neither. I promise
I'm not a dummy, and my logic skills are very strong, but this really
is a whole new world for me.
>From my study of MVC the role of the controller component is most
confusing to me. Traditionally, it seems that the controller was used
in os-based software to manage input from the user, the actual data
type handling, etc, where on a statically typed language or os-based
software that is more of an issue. Reading a Developer's Library book
called "Advanced PHP Programming" by a guy named George Schlossnagle
(who seems like a fairly bright programmer) the assertion is made that
the controller is irrelevant to the web because the browser handles
all the input. Obviously that's not the stance of a big part of the
community, as frameworks like Symfony, etc make a big deal out of the
controller. The PHP-framework implementation of a controller seems to
be more abstract than in os-software.

So my question is, if I were to implement a controller, what I gather
is basically that the model component would be comprised of only
classes with no procedural execution, and that the controller would
primarily be responsible for all instantiation of the model's business-
logic classes? Is that the idea? I realize I may be asking for an
answer that involves personal preference but if you have one, please
let me know. Thank you in advance!

Ricky

May 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On May 18, 8:54 am, "rickycorn...@gmail.com" <rickycorn...@gmail.com>
wrote:
Greetings All,

I had a question about OO implementation in theMVCpattern that is
directed at anyone who feels experienced with it.

My fuzziness comes from trying to learn OOP andMVCat the same time,
coming from a procedural background where I used neither. I promise
I'm not a dummy, and my logic skills are very strong, but this really
is a whole new world for me.
From my study ofMVCthe role of the controller component is most

confusing to me. Traditionally, it seems that the controller was used
in os-based software to manage input from the user, the actual data
type handling, etc, where on a statically typed language or os-based
software that is more of an issue. Reading a Developer's Library book
called "Advanced PHP Programming" by a guy named George Schlossnagle
(who seems like a fairly bright programmer) the assertion is made that
the controller is irrelevant to the web because the browser handles
all the input. Obviously that's not the stance of a big part of the
community, as frameworks like Symfony, etc make a big deal out of the
controller. The PHP-framework implementation of a controller seems to
be more abstract than in os-software.

So my question is, if I were to implement a controller, what I gather
is basically that the model component would be comprised of only
classes with no procedural execution, and that the controller would
primarily be responsible for all instantiation of the model's business-
logic classes? Is that the idea? I realize Imaybe asking for an
answer that involves personal preference but if you have one, please
let me know. Thank you in advance!

Ricky
The work of the controller is to perform basically the common routines
that would otherwise have been done individually in each class. This
includes authentication, input validation and sanitization, processing
requests, and displaying messages.
The controller can be single file like index.php (just an entry
point). This can be either procedural or OOP. There is no much
advantage of using OOP here. Or it can be implemented as part or
component of the superclass.
The drawback to having it in a file like index.php is that you have to
include the class file in the url and also it may not be search engine
friendly. But its advantage is that objects are instantiated in one
file while if you had the controller int he superclass you have to
instatiate each object in its own class.
May 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.