Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- MVC/OO pattern clarification
May 18, 2007, 1:54 pm
rate this thread
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.
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!
Re: MVC/OO pattern clarification
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.
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — The site's Newest Thread. Posted in » Secure Shell Forum