Daniel Jomphe home

10 Reasons To Strictly Separate The V In MVC

31 Mar 2009 » First Published
31 Mar 2009 » Last Updated

Article Status: Draft Release 0.1.0

A few months ago, I spent some time researching better MVC practices. After discussing about it with my colleagues, I researched the following reasons why a business would want to strictly separate the V in MVC from MC.

Note that the following points are of course only true of a MVC app which started from day 0 with a V template engine that strictly enforces separation of V from MC.

  1. V template engine easier and faster to learn
    • No need to learn a (nearly-/fully-)turing-compliant language
    • No need to learn best practices to avoid entangling with MC
  2. V faster to write
    • Impossible to write business logic in V
    • Programming constructs easier to use
    • Final appearance/structure easier to understand/visualize
    • No need to review to make sure V avoids entangling with MC
  3. V faster to maintain
    • Impossible for V to introduce bugs in business logic
  4. V more generic/general/reusable
    • Each part of a template is more applicable to other apps
      • A template can be composed of multiple templates
      • Each purpose-specific template will look pretty much the same in different apps.
  5. V more easily secured
    • No control structures used
    • No business logic in V
  6. V easier to swap for a sexier V
    • No business logic in V
  7. V introduces 0 bugs in an app’s business behavior
    • Only possible bugs are presentation-related
  8. V can be written/maintained by designers (or others)
    • See previous points.
  9. V and MC can be written concurrently more easily and naturally
    • See previous points.
  10. Debugging faster than with traditional MVC apps
    • All business-related behavior bugs are in MC
      • No need to look at V for business logic
    • Proper MC design more emphasized
      • MC completely reflects the business logic

Consequently, I think it’s safe to say that with strictly-enforced separation of V from MC:

Or, on a business point of view:

A Practical Solution

Although it’s not yet as popular as some non-strict alternatives like Velocity and FreeMarker, StringTemplate is the most serious and solid strict V // MC template engine I know of. If you can integrate it in your projects, you won’t be disappointed:

http://www.artima.com/lejava/articles/stringtemplate.html