Sunday, April 27, 2008

MVC

one of the most popular architecture to be used in web development is MVC, yes because the simplicity of it's design which concentrate on how to separate responsibility between each logical part of the system, makes it easy to develop a system in the scale of enterprises. There are three main part of the system that implement MVC design.

Model, why didnt they call it VCM, or CVM, or VMC, etc.. why model first? in my perspective its because the whole thing that make our application work as expected is in the Model, this is our business logic lies, most people prefer it as domain model, this is where we'd play so many entity/business objects based on it's business rules in conjunction to the model functionality. A good model is a coherent one, which concentrate on specific functionality of system. MVC doesn't say much bout statefullnes of model, but in my experiences almost all of my model is statefull, meaning that it store information about what its doing now, what it have done before, and (probably) where it'll going.. -CMIIW-

Controller, most of the time controller is smaller than model or view, why? because its sole responsibility is to do simple validation on the request, determine what model should serve that request, load up the model, and hand off everything to the presentation layer(view) to render the result. Even though, it doesn't mean it will be simpler than any other part, and if you just start learning, theres a big probability that you'll mixed up with controller concept in event-driven-programming(I'll write about it later..), this part doesnt have logic in them, but depends on its design it may have to acquire some knowledge bout list of available views and models. There are several pattern to implement a Controller, some of them are Front Controller pattern, and Page controller pattern, Front controller is widely used by most of GUI framework these days where theres only a single controller to handle every request. And Page controller is a basic concept of controller in most of web application even those that didn't use MVC architecture.

VIEW, finally this is the part where all eyes will look(literally). it can be simple, but it can be even more complicated than model, depends on what kind of application we're tryin to make. personally i get frustated with this part a lot, well I'm no designer :). The idea is factor out gui-unrelated code as much as possible from it, so the change from the view will hardly effecting the model/business model, but the change from model may still affecting the view(think about it..).

well, thats about 13minutes typing on the fly, and I'm sure there are lot of typo there. Its based on what I've done before and frankly I'm still in learning, just writing it down as is, and in the future I'd know what i've been missing :)

No comments: