I have a somewhat different take on this, though a similar
philosophical objective.
(FWIW, lots of background in OOD and OOP in Smalltalk and JavaScript,
but fortunately no Java or C++ taint.)
Models, Views and Controllers do not exist in a hierarchy in which it
makes sense to me (YMMV) to think about “pushing everything layer by
layer towards the model.” Models, Views and Controllers all have
their individual and vital roles to play in an application. But
moving things from a model to a controller, e.g., only makes sense if
you realize that you’ve done something functional or operational in a
model because functionality and operationality belong in controllers,
not in models.
That said, code reusability comes from pushing things “up” the class
hierarchy to the highest level of abstraction that still makes sense.
Virtually all of the refactoring I’ve done in my OO experience has
involved that process, not shifting code from a model to a view or
from a view to a controller unless, as I say, I find I’ve just made a
bad decision at some point in which case that’s not refactoring, it’s
error correction!
Chapter 2 of Agile Web D. explains MVC pretty well. Models
are for holding the state of the app. Views are for generating UIs.
Controllers manage the app and the interaction between the model and
the view. The trichotomy is pretty clean most of the time. I find
that if I’m spending time trying to figure out where to put a
particular class or method, I need to take a step back and ask myself
what the purpose of the new code is. Very often, what results from
that process is a discovery that i need to factor into two pieces of
code, one in the controller and one in the view (at least that’s
where most of my confusion sorts out).
HTH.
On Jan 17, 2006, at 5:19 PM, Bruce B. wrote:
Since views are the surface, the controller the mantle (if I may
stretch my analogy) and the models are the core - I’d push
everything layer by layer towards the model until it made no sense
to continue. As I understand MVC, Views are not meant to be
“intelligent”, they are like store windows that merely present what
is put in them.
Bruce
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
Dan S.
Technology Visionary - Technology Assessment - Documentation
“Looking at technology from every angle”