Differences between revisions 2 and 3
Revision 2 as of 2004-03-12 19:36:15
Size: 3213
Editor: AaronFarr
Comment: added resources section -farra
Revision 3 as of 2009-09-20 23:16:54
Size: 3212
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 40: Line 40:
As we can see MVC is a type of Separation of Concerns. There are numerous advantages to this approach of software design, one of which is the easier application of [wiki:WhatIsIoC Inversion of Control]. As we can see MVC is a type of Separation of Concerns. There are numerous advantages to this approach of software design, one of which is the easier application of [[WhatIsIoC|Inversion of Control]].
Line 46: Line 46:
  * [http://www.research.ibm.com/hyperspace/ Multi-Dimensional Separation of Concerns]   * [[http://www.research.ibm.com/hyperspace/|Multi-Dimensional Separation of Concerns]]

Separation Of Concerns

Separation Of Concerns (SoC) is a DesignPattern which states that problems can be seperated into a set of components each of which focus on only one core concern.

A Simple SoC Example

In order to understand SoC, let's look at a simple example: Java Servlet Programming.

When Java servlets first arrived on the scene, it wasn't too hard to find web application designed like this:

                           +-------------------------------------+              ___________
  +----------+             |    SERVLET                          |             (           )
  |          |             |     o parses request                |             |`----------|
  | BROWSER  | <== HTTP ==>|     o retrieves data from database  | <-- JDBC -->|           |
  |          |             |     o creates HTML results          |             | DATABASE  |
  +----------+             |                                     |             |           |
                           +-------------------------------------+             \-----------/

While for simple applications this design worked just find, it quickly became unmanagable as the problem scales. Any change to the HTML look and feel would require recompiling the servlet. Business logic and display logic was closely tied together. This is an example of no seperation of concerns. Everything jumbled together in one monolithic heap.

Thankfully designs and technology evolved and we soon saw a new design pattern being applied to Java web applications -- Model View Controller (MVC). The MVC appraoch divides the single monolithic servlet into a Model (handles business data and rules), a View (handles presentation logic), and a Controller (parses request and controls execution flow). Various web frameworks built on this MVC idea such as Jakarta Turbine and Jakarta Stuts. So instead of the one servlet above, we end up with:

                                +------ web application ---------+
                                |                                |
   +------------+               |    +---------------+           |             
   |            | === HTTP ===> +--> |  CONTROLLER   | --|       |              ___________
   |            |               |    +---------------+   V       |             (           )
   |  BROWSER   |               |                     +-------+  |             |`----------|
   |            |               |    +----------+     | MODEL | ------JDBC---->|           |
   |            | <=== HTTP === |----|   VIEW   |     +-------+  |             | DATABASE  |
   +------------+               |    +----------+ <-------|      |             |           |
                                +--------------------------------+             \-----------/

As we can see MVC is a type of Separation of Concerns. There are numerous advantages to this approach of software design, one of which is the easier application of Inversion of Control.

Additional Resources

If you'd like to learn more about SoC:

SeparationOfConcerns (last edited 2009-09-20 23:16:54 by localhost)