Dennis’s Weblog

Model-view-controller

Posted on: October 9, 2008

Model-view-controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application and the business rules used to manipulate the data; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages details involving the communication to the model of user actions such as keystrokes and mouse movements.

As an architectural pattern

It is common to split an application into separate layers that run on different computers: presentation (UI), domain logic, and data access. In MVC the presentation layer is further separated into view and controller.

MVC is often seen in web applications, where the view is the actual HTML page, and the controller is the code that gathers dynamic data and generates the content within the HTML. Finally, the model is represented by the actual content, usually stored in a database or in XML nodes, and the business rules that transform that content based on user actions.

Though MVC comes in different flavors, control flow generally works as follows:

  1. The user interacts with the user interface in some way (e.g. presses a button).
  2. A controller handles the input event from the user interface, often via a registered handler or callback.
  3. The controller notifies the model of the user action, possibly resulting in a change in the model’s state. (e.g. controller updates user’s Shopping cart).[3]
  4. A view uses the model (indirectly) to generate an appropriate user interface (e.g. the view produces a screen listing the shopping cart contents). The view gets its own data from the model. The model has no direct knowledge of the view.
  5. The user interface waits for further user interactions, which begins the cycle anew.

As a design pattern

MVC encompasses more of the architecture of an application than is typical for a design pattern.

Model
The domain-specific representation of the information on which the application operates. Domain logic adds meaning to raw data (e.g., calculating whether today is the user’s birthday, or the totals, taxes, and shipping charges for shopping cart items).
Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the Model.
View
Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.
Controller
Processes and responds to events, typically user actions, and may invoke changes on the model

_________________________________________________________________________________________________________________________________________________________________________________________________

Alfresco Share – MVC

This product was divided into three part:

  1.  If you want to motify the data relatived, you just simple modify its XML file, and can refer to http://wiki.alfresco.com/wiki/Developer_Guide

For example: motify the login language.

    2.    modify the View, you should modify it’s JSP file, you can find in alfresco home directory.

    3.    modify the logic, you should compile the “Jar” file yourself, and you can find the path of these jar in Jsp code.  (java servlet/beans).

_________________________________________________________________________________________________________________________________________________________________________________________________

You can aware of two important design concept:    Hierarchy and Loosely Coupled.

Hierarchy:    different part have their own functions.

Loosely Coupled:   They are not interdependented.  Couple only through some interface (Or standard, such as XML).

Reference:

http://en.wikipedia.org/wiki/Model-view-controller#As_a_design_pattern

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: