CSC/ECE 517 Fall 2007/wiki3 6 aa: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 28: Line 28:
The working clearly indicates the semblances of the MVC pattern.
The working clearly indicates the semblances of the MVC pattern.
[[http://en.wikipedia.org/wiki/Smalltalk]]
[[http://en.wikipedia.org/wiki/Smalltalk]]
== An Example ==
=== Http Request ===
  Browser          View              Controller      Model
    .                .                .              .
    . HTTP Request    .                .              .
    +---------------------------------->+              .
    |                .                | update model  .
    |                .                +-------------->+
    |                .                |              |
    |                .                | return status |
    |                .                +<--------------+
    |                .    select view |              .
    |                +<----------------+              .
    |                |                .              .
    |                | query state    .              .
    |                +-------------------------------->+
    |                |                .              |
    |                |                .  return state |
    |                +<--------------------------------+
    |  HTTP Response |                .              .
    +<----------------+                .              .
    .                .                .              .

Revision as of 00:31, 20 November 2007

Topic

Controller Pattern

Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.

What Is

Controller Pattern

This is usually also called as Model-View-Controller Pattern. The essence behind this is that when the business logic or data access components are large, a Controller class is introduced between user interface (View) and the core logic (Model).

A very good example for this is the Java Swing Architecture. In Swing, all GUI is defined via objects and classes derived from the JComponent object. The business logic is defined in ActionListeners, Event Descriptors.

To put things simply,

An easy way to understand MVC: the model is the data, the view is the window on the screen, and the controller is the glue between the two. -- ConnellyBarnes

SmallTalk

However intuitive and simple idea it is, it has an origin in this work and its inventors (TrygveReenskaug and others). Lets discuss how it actually works. This is not a chat application as is usually the perception, but is actually a language that is inspired by the desire to make human computer interaction simpler and smoother. The language has the concepts of object oriented Programming and each object has only following properties,

  1. Hold state (references to other objects).
  2. Receive a message from itself or another object.
  3. In the course of processing a message, send messages to itself or another object.

The state an object holds is always private to that object. Other objects can query or change that state only by sending requests (messages) to the object to do so. Any message can be sent to any object: when a message is received, the receiver determines whether that message is appropriate.

The working clearly indicates the semblances of the MVC pattern. [[1]]

An Example

Http Request

 Browser           View              Controller      Model
   .                 .                 .               .
   . HTTP Request    .                 .               .
   +---------------------------------->+               .
   |                 .                 | update model  .
   |                 .                 +-------------->+
   |                 .                 |               |
   |                 .                 | return status |
   |                 .                 +<--------------+
   |                 .     select view |               .
   |                 +<----------------+               .
   |                 |                 .               .
   |                 | query state     .               .
   |                 +-------------------------------->+
   |                 |                 .               |
   |                 |                 .  return state |
   |                 +<--------------------------------+
   |   HTTP Response |                 .               .
   +<----------------+                 .               .
   .                 .                 .               .