ddobrev81/LearnsiteMVCRewrite — pull request #1 by leprechaun (2013-11-04 15:46:49+00:00)
Title: A few comments

Alright, so your site was a bit more organized. Good.

I did a small fix on classes/Controller.php. There's less repetition, less code and no useless break in that case.

I also added a "kind of" model for "shoutbox2". I still wouldn't quite call this MVC, but it's getting a bit closer. Look at apps/shoutbox2/controller.php. It's more of a model/domain that it is a controller in fact.

What's nice about that approach is that your shoutbox2 domain is encapsulated within a class. Any variables declared are local to shoutbox2 and can't leak out. The inclusion of the database connection and stuff is hackish, and would probably lead your site to connect more than once per page view, depending on what happens outside of shoutbox2.

$shoutbox->post()
$shoutbox->display()

Now ... how about if $shoutbox strictly returned data structues, eg, a plain object, or array?

$shoutbox -> display() => array( array('id'=>123, 'user'=>'leprechaun','subject'=>'this is test', 'message'=>"this is the body of the message")

How about if there were more than one way of displaying that data? How about RSS/XML for make a feed? How about json for who knows who? How about displaying a little shoutbox widget on every page? Could you see how that class returning data instead of presentation/html be useful?

How and where would you mash the data and html together?