Shouldn't the MVC become MVCS

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Shouldn't the MVC become MVCS

Post by Christopher »

VladSun wrote:OK, I surrender :lol:
It all started because of the many similarities between the View and the Storage layer.
I'll try to implement a prototype some day, but for now it's not clear enough even for me, haha :)

Thanks again guys.
Don't surrender, I still have not understood what those similarities are that you are seeing. You can't just leave use confused! ;) You may be on to something interesting...
(#10850)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Shouldn't the MVC become MVCS

Post by Christopher »

webaddict wrote:User::render( ); // for displaying purposes.
User::save( ); // for persisting into a Mysql database.
User::login( ); // querying the database.
User::setPassword( ); // for changing the password.

Now, think it through. Which reasons can there be to change the object? The displaying may vary (xml, html). Persisting might vary too (say I want to use a better database, such as Postgresql), logging in might change. Setting the password however isn't something expected to change. Now think about the principle: "encapsulate what varies". What've you got left? Yes, something that renders, something that controls, ( something that contains the bussinesslogic and something that persists).
That is a really excellent description of how you use SRP to go from monolithic code to modular code -- ending up with MVC. Very nice ... it adds another perspective from which to understand MVC!
(#10850)
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Shouldn't the MVC become MVCS

Post by josh »

Database tables can be referred to as "views", I think what he's getting at is that you might want to change code to not output a table, but maybe save that data to a database and forward to some other action ( changing an action that renders models to an action that persists those models ), like instead of passing a model to the view renderer it'd be passed to a data mapper, but this would still be following MVC ( unless you implemented that data mapper as a view ), the only thing you'd be changing is the controller
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Shouldn't the MVC become MVCS

Post by josh »

Supposedly this is the logic behind this http://alistair.cockburn.us/Hexagonal+architecture
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Shouldn't the MVC become MVCS

Post by Christopher »

I really don't see how that is any different than a Front Controller and Router. He calls is 'ports' but it just sounds like a dead-end version of routes. I am always suspicious of anything around Responsibility Driven Design, which seems like a mini-alternate-universe with different names for many common ideas and patterns.

Still I am confused...
(#10850)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Shouldn't the MVC become MVCS

Post by VladSun »

jshpro2 wrote:Database tables can be referred to as "views", I think what he's getting at is that you might want to change code to not output a table, but maybe save that data to a database and forward to some other action ( changing an action that renders models to an action that persists those models ), like instead of passing a model to the view renderer it'd be passed to a data mapper, but this would still be following MVC ( unless you implemented that data mapper as a view ), the only thing you'd be changing is the controller
Yes, it's the closest description (and it's in better English than mine, hahaha).
There are 10 types of people in this world, those who understand binary and those who don't
webaddict
Forum Commoner
Posts: 60
Joined: Wed Mar 14, 2007 6:55 am
Location: The Netherlands

Re: Shouldn't the MVC become MVCS

Post by webaddict »

arborint wrote:That is a really excellent description of how you use SRP to go from monolithic code to modular code -- ending up with MVC. Very nice ... it adds another perspective from which to understand MVC!
Thanks arborint, I'll take that as a huge compliment, coming from someone with your knowhow.
Post Reply