Page 1 of 2
MVC is pretty nice
Posted: Sun Apr 23, 2006 6:04 pm
by alex.barylski
When the idea clicked originally, I wasn't impressed but I spent all last night working on how my new project would work with it...
I must now say after spending all day today coding a basic modular framework, it'll be quite nice when the brick and mortor (I just realized I can't spell mortor???

)is all complete...
The way I structured my file system and the way the MVC framework works with it will really accelerate my development and make it much easier to contract work out or get others to help me along...
Should be cool...
If I keep interested in this project...it'll be nice to see how it goes
Cheers

Posted: Sun Apr 23, 2006 6:07 pm
by alex.barylski
Also just wanted to say...
I've had some really cool ideas for template engines and O/RM...both of which should tie in nicely with my current setup...
Lot's of building to do though

Posted: Sun Apr 23, 2006 6:20 pm
by Chris Corbyn
Yeah MVC is incredibly useful.... it also varies vastly in it's implementation.
Re: MVC is pretty nice
Posted: Sun Apr 23, 2006 6:32 pm
by Christopher
Hockey wrote:When the idea clicked originally, I wasn't impressed ...
Two comments.
First I am often suprised at people being "not impressed" with the ideas that come from the greatest minds in today's software development community. Whether it is OOP or Patterns or Agile Methodologies or TDD there is frequently this strange resistance. Given that I spend much of my design time struggling to fully grasp the meaning in the words I read about these subjects, it is a little jarring to hear someone say they are "not impressed." Especially when the ideas have been around many years and are fairly well proven as practices.
Second, it sounds like the idea of MVC didn't actually "click" orignially, but now has.
Posted: Sun Apr 23, 2006 7:16 pm
by John Cartwright
Believe me, my learning curve when it comes to design principles can sometimes be very gradual. Once you really get down and dirty, rewritting applications over and over learning and improving everytime, you seriously will learn to love it, be it a day or a year. There are developers who simply don't believe in it and that is completely cool if that's the path they choose, but for your own sake give it a chance

Posted: Sun Apr 23, 2006 7:53 pm
by alex.barylski
d11wtq wrote:Yeah MVC is incredibly useful.... it also varies vastly in it's implementation.
So i've discovered...
I'm using a very modular approach, but have changed the over method 3 times already...
Seeking that optimal ease of use versus performance
Just curious, as I was going to ask this question shortly anyways...
Do you use a dynamic plugin approach to MVC loading or do you hard code your front controller using switch statements...
I assume the front controller would use $_GET variables to determine which MVC triad is executed...I know there other ways, but this is what i'm using as of now...
How do you implement MVC and more specifically the front controller...
It's basically what I've been using for years and trying to accomplish (As I love the idea of a single application entry point) but haven't done so until now...Story of my life...

Posted: Sun Apr 23, 2006 8:00 pm
by alex.barylski
Well...as hard as try to be open minded to change, especially if it's obviously for the better...
I'll sound foolish saying this, but I've been programming along time and feel very much like a veteran

only much younger in physical age...
I am not easily convinced because my ways have worked for years, so why would I change...despite knowing that not everyone can specialize in everything and it's best to learn from others mistakes, because we don't live long enough to learn from our our own (or however that saying goes - it's quite popular with pilots

for obvious reasons)
Anyways, I really do try and break free of arrogance and accept new methodologies, etc...but it's difficult for me until I have reached a point where I am convinced there must be a better way...
I appreciate you all walking me through the process and offering assiatance while I tried to grasp the idea of MVC...it really helped once I started to get it...and helped really solidify in my mind what it was..
Unless I still don't get it, but i'm pretty sure I do...it was really like a light switched flipped on and when I prototyped an application on paper using MVC I was like whoa...that is cool...and started immediately implementing an MVC skeleton
Cheers

Posted: Sun Apr 23, 2006 8:11 pm
by John Cartwright
Do you use a dynamic plugin approach to MVC loading or do you hard code your front controller using switch statements...
I think some of us have had the case of miscommunication past day or two, what do you specifically consider a plugin?
From that statement I take it you mean an action of a controller, right?
Code: Select all
class fooController
{
function defaultAction { }
function addFooAction { ]
}
From what I've seen from most frameworks is they use this convention.
http://localhost/foo/addFoo or something like
http://localhost/index.php?module=foo&action=addFoo
Am I understanding you correctly?
Posted: Sun Apr 23, 2006 10:37 pm
by Christopher
As is often the case the nomenclature is getting in the way here. Typically the Command pattern is what is associated with a Front Controller in that all Actions have or follow a standardized interface (such as Jcart's fooController conforms to).
The Plugin pattern is usually an alternative for a Factory where you don't want to keep adding things to the Factory code, but instead be able to plug in new code at run-time.
Posted: Mon Apr 24, 2006 7:04 pm
by alex.barylski
Miscommunicationed is the root of all evil I tells ya
What I mean, was...
First descirbing what I condiered:
1) Front Controller - Acts like main() or WinMain() (in theory) in a C++ program...provides a single applcation entry point...and dispatches controller requests to appropriate controllers, which take care of the rest...
2) Controller - Takes care of request specifics...either using the model to pull data for rendering in a template engine, etc...or carries out tasks like manipulating the model...ie: adding a record to a database table...
Which leads me to a question:
Would say it is safe to assume there are two types of controllers:
1) View controller
2) Model controller
Both of which I guess are controller-controllers?
Anyways, back to original:
I wanted to know how you implemented front controllers I guess...
Here is what I mean:
Code: Select all
define('CTRLID_CREATE_USER', 1); // Model only controllers
define('CTRLID_UPDATE_USER', 2);
define('CTRLID_DELETE_USER', 3);
define('CTRLID_DISPLAY_USER', 4); // View only controller
$ctrl = (int)$_GET['ctrl'];
switch($ctrl){
case 'CTRLID_CREATE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->createUser();
break;
case 'CTRLID_UPDATE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->updateUser();
break;
case 'CTRLID_DELETE_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->deleteUser();
break;
case 'CTRLID_DISPLAY_USER:
include_once('./models/ctrl.user.php');
$o = new CxUserController();
$o->displayUser();
break;
}
This way is static and requires hard coded changes...
I wanted to know if you all used a more dynamic or plugin approach to solve this problem or if you find the hardcoded bit much effort maintaining?
Cheers

Posted: Mon Apr 24, 2006 7:43 pm
by alex.barylski
I should also now ask,
If you use factories to instantiate controller objects, do your objects use a standard naming convention for both class and methods or do you use XML mapping approach or something similar?
Cheers

Posted: Mon Apr 24, 2006 10:12 pm
by Christopher
Hockey wrote:If you use factories to instantiate controller objects, do your objects use a standard naming convention for both class and methods or do you use XML mapping approach or something similar?
You can do either, though XML mapping is condsidered old-school Java style these days. RoR made convention over configuraton the current trend. That style uses URL in the form
http://www.mysite.com/class/method/ (usually named /controller/action/) but you can also use a standard method name and just dispatch classes. Sometimes they add "Controller" to the class names and "Action" to the method names. I could never figure out why you want to spend processing time creating fancy names though.
There is a very simplified Front Contoller
here and my fork of the Skeleton code is
here. That Front Controller / Mapper design was by kyberfabrikken. I am currently working on an update to that Skeleton code that is has RoR style routing and the naming changed to PEAR / Zend Framework style.
Re: MVC is pretty nice
Posted: Mon Apr 24, 2006 10:27 pm
by Roja
arborint wrote:First I am often suprised at people being "not impressed" with the ideas that come from the greatest minds in today's software development community.
Keep in mind that not all of the greatest minds in today's software development community are in agreement on pretty much *any* topic - whether it is oop, or TDD, or Agile, or XP, or Pair Programming, or MVC...
Thats why an open mind shouldn't be "surprised" at people with different opinions. There are lots of them out there.
I happen to agree in most cases (OOP, MVC, etc), but your surprise to me indicates either you don't realize how many people disagree, or you don't realize why. In either case, its not a shortcoming of the people disagreeing with a given position - its your lack of understanding of their position that is.
arborint wrote:Whether it is OOP or Patterns or Agile Methodologies or TDD there is frequently this strange resistance. Given that I spend much of my design time struggling to fully grasp the meaning in the words I read about these subjects, it is a little jarring to hear someone say they are "not impressed." Especially when the ideas have been around many years and are fairly well proven as practices.
Age, and general applicability do not make for perfection in all cases. Or else we'd only eat McDonalds.
Re: MVC is pretty nice
Posted: Mon Apr 24, 2006 11:52 pm
by Christopher
My suprise is not that experienced developers with extensive knowledge about these ideas express a variety of perspectives about them. It is that programmers who are younger than many of these ideas (MVC is over 30 year old) and who know very little about them say they are "not impressed" by them. I fault myself for this as well.
I also don't see the disagreements. When I look around at leading web development being done in C#, Java, PHP, Python, or Ruby it all looks suprisingly similar, especially with regards to OOP, Patterns, Agile methologies, Unit Testing, etc.
Posted: Tue Apr 25, 2006 12:48 am
by wtf
Speaking of MVC, PHP and RoR... Here's a very interesting article
http://codesnipers.com/?q=node/156