Welcome Guest, Not a member yet? Register   Sign In
MVC - Controller Questions
#2

[eluser]Randy Casburn[/eluser]
You've generated what will amount to a religious diatribe of beliefs about your topic...but hey, it's all in fun right.

Your thinking is correct. The Controller in a classic MVC design pattern was originally established to employ an observer pattern that would receive events from the UI componentry of the application and that observer pattern implementation would invoke the controller in order to respond in specific fashion to the singular event presented by the observer. So, yes you are correct.

Since these things all happened in a tightly coupled environment, or at least a tightly controlled environment, all the parts and pieces were well understood. In today's web based environment it can be argued that the observer for HTTP event is your web server implementation (Apache, IIS, etc.), that the JavaScript interpreter in your browser maintains it's own observer through it's own event manager, the PHP virtual machine (interpreter) has it's own observer and finally CodeIgniter's front controller (codeigniter.php) acts as the observer for CI.

Reacting to all the variations in event management characteristics may, in fact, require a CI controller to react differently depending upon the characteristics of the event. An overly simplistic example of this is demonstrated by the fact that both the web server and CI have implemented responses to the inevitable "page not found" event. In the classic synchronous (tightly coupled) environment this duplication would not be necessary.

I agree with you that designing controllers as classes that create functional "objects" is a flawed design approach. If this is what has happened, it would seem to indicated this capability is more appropriately established as a class in a library that is instantiated from within a controller when needed. But you should immediately notice that the class must be instantiated. Ah, so no performance is gained anyway since the entire object must be constructed anyway.

All this for a script that is going to live for approximately....0.04435 seconds

Let the deluge begin ;-)

Randy


Messages In This Thread
MVC - Controller Questions - by El Forum - 09-27-2008, 08:40 PM
MVC - Controller Questions - by El Forum - 09-27-2008, 09:11 PM
MVC - Controller Questions - by El Forum - 09-27-2008, 11:59 PM
MVC - Controller Questions - by El Forum - 10-03-2008, 04:22 PM
MVC - Controller Questions - by El Forum - 10-03-2008, 04:44 PM
MVC - Controller Questions - by El Forum - 10-04-2008, 01:47 PM
MVC - Controller Questions - by El Forum - 10-04-2008, 04:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB