Differences between revisions 4 and 5
Revision 4 as of 2006-08-11 13:43:49
Size: 469
Editor: BenGolding
Comment:
Revision 5 as of 2006-08-13 04:08:17
Size: 2651
Editor: BenGolding
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
== Model-View-Controller Overview == = Overview of MVC in Albatross =
Line 5: Line 5:
 * Simple overview of MVC
 * Draw a little MVC diagram
 * directory structure should follow MVC paradigm
XXX Draw a little MVC diagram

The three components each have specific roles within the application:

 * Controller
   The controller drives the application. In a typical request, it will load models into the session context, request that they be presented to the user, and when the user responds, it will carry out an appropriate action, say, to save the values back to the database, request more information from the user, or to move the application into the next state.

   In an Albatross application, the controller is a state machine. Each time the application moves to a different state -- say, from login, to item selection, to item detail -- the controller will move in a state transition using the {{{set_page}}} method.

 * Model
   The model is the set of objects that the application deals with on the server. Typically they are stored in a database and the controller will coordinate loading them.

   This structure makes the models independent of the application itself so that they can be reused or tested independently of the application, say using unit testing.

 * View
   In Albatross, the view is the .html page that contains the Albatross tags to display the information that was prepared by the controller and saved in the session context.

The clear separation of each of these roles within the application helps contain application complexity and improves reuse and reliability. The data store can be changed with minimal impact on the controller, additional states can be added, and the display presented to the user can be tailored (using CSS perhaps) without needing changes to the models or controller.

In practice it's hard to partition these three functions cleanly but it's worth striving for.

= Application Directory Structure =

XXX should follow MVC paradigm

= How to design an Albatross application =

Draw a state diagram for the application. Each state will represent a controller class which will manage the transitions.

Design the models required to hold and update the users' interactions with the web site and implement them appropriately.

Layout the pages to be presented to the user and implement them to display the models' information as provided in the session context.

= Simple application example =

Albatross does not impose any particular application structure. Following a standard structure makes a developer's life much easier. The standard application design for applications using a user interface is MVC, model-view-controller, and this is ideal for designing usable and maintainable Albatross applications.

Overview of MVC in Albatross

XXX Draw a little MVC diagram

The three components each have specific roles within the application:

  • Controller
    • The controller drives the application. In a typical request, it will load models into the session context, request that they be presented to the user, and when the user responds, it will carry out an appropriate action, say, to save the values back to the database, request more information from the user, or to move the application into the next state.

      In an Albatross application, the controller is a state machine. Each time the application moves to a different state -- say, from login, to item selection, to item detail -- the controller will move in a state transition using the set_page method.

  • Model
    • The model is the set of objects that the application deals with on the server. Typically they are stored in a database and the controller will coordinate loading them. This structure makes the models independent of the application itself so that they can be reused or tested independently of the application, say using unit testing.
  • View
    • In Albatross, the view is the .html page that contains the Albatross tags to display the information that was prepared by the controller and saved in the session context.

The clear separation of each of these roles within the application helps contain application complexity and improves reuse and reliability. The data store can be changed with minimal impact on the controller, additional states can be added, and the display presented to the user can be tailored (using CSS perhaps) without needing changes to the models or controller.

In practice it's hard to partition these three functions cleanly but it's worth striving for.

Application Directory Structure

XXX should follow MVC paradigm

How to design an Albatross application

Draw a state diagram for the application. Each state will represent a controller class which will manage the transitions.

Design the models required to hold and update the users' interactions with the web site and implement them appropriately.

Layout the pages to be presented to the user and implement them to display the models' information as provided in the session context.

Simple application example

None: Application_design (last edited 2011-02-15 06:05:18 by localhost)