Page 2 of 2

Re: Have I got MVC all wrong?

Posted: Tue Sep 26, 2006 4:05 pm
by Buddha443556
arborint wrote:... whole quote it is about enabling the user to have the illusion of manipulating the domain. So more important to programmers would be to clarify the domain -- which is a major thrust in modern design thinking.
I thought the thrust of modern design was to incorporate the mental model of the end users with the domain model of the programmers by making the end user one of development team. Isn't that what all that "stakeholder" stuff in XP and Agile Development is about? I think Reenskaug and his ilk were way ahead of there time IMO.

We differ as usual. :D

Posted: Tue Sep 26, 2006 7:38 pm
by Ambush Commander
Wow, a lot of replies. I guess it's to be expected: we haven't had many MVC threads for a while.
I don't think you have Fowler right. I don't think your description of Cake is right from my experience of the code, but if that is their naming the it is wrong.
So... my understanding of MVC is wrong, and my understanding of CakePHP's model is wrong, but I was correct to object to the naming of database access as a model. Hmm... I'm really clueless. ^_^"
That is not confusing MVC because the dependencies are all still correct -- the Datasource only know about itself, the Model know about the Datasource, and the Controller know about both.
I was under the impression that depending on the implementation, the datasource may or may not know about the model, and the model may or may not know about the datasource. For example, the Data Mapper pattern is all about having the datasource know about the model, but have the model not know about the datasource. Of course, there's different ways to go about this that shift the dependencies.
1. Model -- Domain logic that makes Datasources useful
2. View -- Display logic creates the Response
3. Controller -- Program Flow logic that undertands and manages the Request
I had an "Aha!" moment just right now. I've been dwelling on Fowler's comment that "Whatever the merits of an Application Controller, it's a very different beast from an MVC controller." and realized that he was talking about only the Application Controller and not necessarily the Page/Front controllers. I then reread his earlier comments about what the controller does: "The controller takes user input, manipulates the model, and causes the view to update appropriately." In a PHP context (without AJAX), only the first two points are relevant, but oh are they so important!

Although, it leaves me wondering what the difference between a Transaction Script and a Controller is. And whether or not a PHP page is a degenerate controller.

(I think this pretty much sums up my sentiments about the rest of the comments too).
Cake is great!!! I'll leave it at this.
It doesn't have authentication though. T_T

Re: Have I got MVC all wrong?

Posted: Tue Sep 26, 2006 11:29 pm
by Christopher
Buddha443556 wrote:I thought the thrust of modern design was to incorporate the mental model of the end users with the domain model of the programmers by making the end user one of development team.
I am not sure about 'incorporate' is the right term -- certainly the mental model of the end user needs to be understood. But the mental model and the domain model are certainly not incorporated together. I would still say that the main focus of the programmer is on the design of the domain model.
Buddha443556 wrote:Isn't that what all that "stakeholder" stuff in XP and Agile Development is about? .
I don't think the "client" in necessarily the end user, though it is good to incorporate end users into the process. I really think "stakeholder" is meant to incorporate those who formerly were "problems" or "roadblocks". ;)
Buddha443556 wrote:I think Reenskaug and his ilk were way ahead of there time IMO
I agree and often say that when people accuse methodologies of being fads they are misunderstanding that the methodologists just keep repackaging all these good ideas until eventually the accusers finally get it. ;)

Posted: Wed Sep 27, 2006 12:07 am
by wtf
It doesn't have authentication though. T_T
Here's a start
http://manual.cakephp.org/appendix/simple_user_auth

... and a lot more
http://wiki.cakephp.org/

Posted: Wed Sep 27, 2006 1:43 am
by Christopher
Ambush Commander wrote:I was under the impression that depending on the implementation, the datasource may or may not know about the model, and the model may or may not know about the datasource. For example, the Data Mapper pattern is all about having the datasource know about the model, but have the model not know about the datasource. Of course, there's different ways to go about this that shift the dependencies.
Again, I don't think the Data Mapper is part of MVC and I really think it becomes an intellegent Datasource. A Mapper certainly does not provide any Domain logic.
Ambush Commander wrote:I had an "Aha!" moment just right now. I've been dwelling on Fowler's comment that "Whatever the merits of an Application Controller, it's a very different beast from an MVC controller." and realized that he was talking about only the Application Controller and not necessarily the Page/Front controllers. I then reread his earlier comments about what the controller does: "The controller takes user input, manipulates the model, and causes the view to update appropriately." In a PHP context (without AJAX), only the first two points are relevant, but oh are they so important!
My experience is that Application Controller tend to be state machines are so are in a different realm than MVC (in a different way than the Front Controller is). I know you can build MVC on top of an Application Controller, but I don't think the reverse makes sense.
Ambush Commander wrote:Although, it leaves me wondering what the difference between a Transaction Script and a Controller is. And whether or not a PHP page is a degenerate controller.
A Transaction Script is all the same stuff, it just does not have the clean dependencies.

Posted: Fri Sep 29, 2006 12:49 pm
by alvinphp
Here is a simple example to further explain MVC...

Code: Select all

$obj_model = new cls_model(); //Creating an instance of your MODEL

if(isset($_GET['id'])) { //this is your CONTROLLER as it is handling your request
        $obj_model->set_id($_GET['id']); //updating the id attribute in your MODEL	
        $name = $obj_model->get_name(); //this finds the name associated with the id you set from your MODEL
        echo $name; //this is your VIEW which displays the results
}