On Nov 18, 2010, at 1:31 PM, Fozzyuw wrote:
I believe you answered one of my long standing confusions of MVC
structure
in understanding what a Model really is. Are they all things other
than
Controller/Views Models?
Not exactly. There's also code in your application that is not a
Model. That is, it does not represent a business entity in your
workflow. Often these are "utility" classes. A logger is a good
example. So I think there's a case that we need another directory
besides the trio of controllers, models, and views.
Clearly because there are situations were you
simply have a Table/Data access class, not really a Model of an
object, like
a product (which could have multiple data access classes depending
on how
the database and object was designed).
Right, that's a good distinction between a Model and a Table. A given
Model may access more than one table to perform a given task. Also
note that a Model may interact with other Models. For example, when a
Product gets sold, the Product model could create an Invoice, debit
the Customer's credit, notify a Salesperson, etc. Each of those
could be Models in their own right, and each Model is implemented to
use one or more database tables behind the scenes.
In many ways, as I work more with MVC I start to
question myself if I shouldt be using something like a "require_once"
because I start to feel that there should be "Zend FrameworK" way of
doing
it, like auto-loading.
Yes, there are good reasons to use autoloading, not only for the sake
of Zend Framework, but in general. PHP performance is sensitive to
code bloat, so we should seek to avoid loading code on a given request
if we don't need it. Autoloading allows us to avoid writing lots of
"require_once" calls, and postpone loading code to the point when the
class is referenced.
Regards,
Bill Karwin