[geeklog-devel] MVC package and sample application

Tony Bibbs tony at tonybibbs.com
Sun Mar 23 10:52:07 EST 2003


Blaine Lang wrote:

> Ok - I have the application installed and can see a lot of work was done to
> create these new classes. It initially appears to be a lot more complex and
> you still need to add the template classes which I gather will be the view
> layer.

Yes, this example does not use a template class but in GL2 it would 
without question.  Hopefully you don't see this as too much more 
complex.  Admittedly the base MVC framework (controller.class.php, 
MVC_Base.class.php, etc) can appear to be complicated.  All that us GL2 
developers would need to know, however, is how to build a new controller 
configuration file (which shouldn't be too hard) and then simply build 
the views/models accordingly.

The hardest thing starting is out is understanding object mapping. While 
I don't see a big reason, the command that is typically typed into the 
get string (e.g. http://example.com/?cmd=show) is mapped in the config 
file to a class name (e.g. SaveContact).  Then in the config file you'll 
notice a bunch of _FORWARD objects for a given view or model.  Those 
define all the possible 'next steps' a command can take.  Thus in the 
end of a execute() method you'll see something like "return 'validate'". 
In this case 'validate' is the name of a forward for the current model 
which maps to another command OR does a redirect (doing a redirect for 
forward to another view/model is determined by the _TYPE directive).

I don't like the PHP Array for configuration.  If you look closely I 
have started a config.xml file which I think is easier to read for the 
developers *and* it provides us a way to validate the XML so ensure the 
config file is valid.  I think an XML config file will be more standard 
way of doing configuration but for those who perfer to work with PHP 
isntead, I will rework the array code to some other more intuitive method.

> 
> I recognize there are benefits and re-use via patterns and more OO classes.
> It will just take me a bit to fully understand the architecture and the
> approach. I'm not a JAVA coder or have developed MVC programs before.
> 
> Is this the direction you have in mind for GL2?

Yes, this is the direction I would like to take GL2.  I think the base 
framework will need to change a tad before anything is deemed final but 
the basic MVC framework is one I would really like to use.

> 
> Can you summarize your reasons and benefits you see with this approach vs a
> more standard OO style for the business or model layer with a template
> driven interface for the presentation (view layer) and using data
> abstraction layer.

Actually this represents the approach you just described.  The only 
difference is execution is marshalled by a single object, the 
controller.  Thus if you want to change program flow you need only edit 
the configuration for the controller to forward execution to the proper 
commands or, optionally, redirect to another controller within the 
application (i.e. fowarding control to the admin controller, or the 
Forum controller, etc).  The MVC framework in addition to breaking logic 
into smaller atomic parts for maximum reuse, gaurantees only the code 
needed to process the current request is loaded.

Finally, as we develop the various use cases for a system (i.e. 
saveUser, approveStory, etc) they map directly to views and models in 
this framework so it would be quite easy to send developers off coding 
from those use cases (and requirements of course).

Blaine, I'd encourage you and anybody else to build a simple form that 
does something trivial like, say, adds two numbers together complete 
with validation to get accustomed to this.  As I said I don't want to 
run down a path that the rest of you don't agree with so it is important 
to me that I get a 'yea' or 'nay' from you all.

-- 
+-------------------+--------------------------------------------------+
|Tony Bibbs         |[R]egardless of what you may think of our penal   |
|tony at tonybibbs.com |system, the fact is that every man in jail is one |
|                   |less potential fisherman to clutter up your       |
|                   |favorite pool or pond. --Ed Zern                  | 

+-------------------+--------------------------------------------------+




More information about the geeklog-devel mailing list