Page 3 of 3

Re: MVC - Controller and Model in the same class?

Posted: Wed Dec 22, 2010 1:51 pm
by josh
Technical wrote:Finally, I've come with acceptable and good(I think) solution.
So I made Item and Set classes.
Then, I made

Code: Select all

ContentItem extends Item
and

Code: Select all

ContentSet extends Set
.
Content class is a View.

For example,

Code: Select all

$Item = new ContentItem(1); // Item with ID 1
Content::Item($Item);

$Set = new ContentSet(0, 10); // 10 items
Content::Items($Set);
Thanks everyone for help, I see now that MVC is really better and more useful
You created a controller & models. There is no view that I can see, which makes it 2 tier and not MVC. I'm presuming that you separated display & business logic at the method level instead of the class level.

I never said there's anything wrong with your code, just that its not MVC.

Re: MVC - Controller and Model in the same class?

Posted: Wed Dec 22, 2010 3:09 pm
by Christopher
josh wrote:You created a controller & models. There is no view that I can see, which makes it 2 tier and not MVC. I'm presuming that you separated display & business logic at the method level instead of the class level.
The sense I get is that the Content class (called statically) is the View class and then example shown is the Controller ... but Technical would have to verify that.

Re: MVC - Controller and Model in the same class?

Posted: Wed Dec 22, 2010 3:14 pm
by josh
Ah, well in that case there is a problem with his code. It is MVC but its using bad naming. It should be called View, not Content (especially since it coincides with a model name)

Re: MVC - Controller and Model in the same class?

Posted: Wed Dec 22, 2010 3:18 pm
by Christopher
Yep.

Re: MVC - Controller and Model in the same class?

Posted: Fri Jan 07, 2011 11:09 am
by John Cartwright
Good software engineers deliver. Bad software engineers deliver excuses. Try to avoid working with people that aren't as passionate or capable with a project as yourself.

//back into shadows

Re: MVC - Controller and Model in the same class?

Posted: Fri Jan 07, 2011 1:43 pm
by Christopher
Yeah agreed ... this is yet another "I came in contact with the concept X when I joined a team ... therefore concept X is bad" posts.

Re: MVC - Controller and Model in the same class?

Posted: Fri Jan 07, 2011 9:00 pm
by josh
That post originally had spam links. Its not even a real person. :roll: Why the mods kept it there I don't know, they are too kind.

Re: MVC - Controller and Model in the same class?

Posted: Sat Jan 08, 2011 1:19 am
by Benjamin
josh wrote:That post originally had spam links. Its not even a real person. :roll: Why the mods kept it there I don't know, they are too kind.
I didn't see it but he's gone now. That post was actually from a post or comment on reddit.com. Weird.