Sunday, July 17, 2011

04 About MVC

I assume you are already familiar with the concept of MVC, so I will not elaborate too much about what it is. Suffice to say that it provides you with a way to detach your web design (user interface) from the workflow and your business logic.
  • This means that it becomes easy for you to rearrange your look and feel and it is even possible to outsource the design to some html guru you may know without any risk that this guru will destroy your hard programming work. That is a major benefit!
  • It also means that you can rearrange your workflow without touching your business logic, which makes re-factoring easy.
  • Likewise, you can re-factor your business logic objects without messing up your workflow.
MVC layers are loosely coupled, this means that they are still coupled albeit loosely (duh). The more you practice the principles of MVC, the more adept you become, the looser they will be coupled. In my experience, the trick is to make good use of OO interface and abstraction principles and writing towards an API contract. (How to do this is beyond the scope of this tutorial, but fear not, the conventions in ColdBox will effectively decouple your layers without much thought.)

If you refactor in such a way that the API contract does not change, none of the other layers of the MVC will need to be changed. This requires a good understanding of OO (Object Oriented) concepts and design patterns will also be helpful. Although be careful not to loose your head in design patterns, they are an entire study on its own and will make the step from traditional sequencial scripting to OO seem all the more difficult and discouraging. Take baby steps!

Some nice resources on MVC:
Some nice resources on Design Patterns:

So how does this work in ColdBox?

No comments:

Post a Comment