Differences between revisions 9 and 10
Revision 9 as of 2006-08-14 13:10:58
Size: 3263
Editor: BenGolding
Comment:
Revision 10 as of 2011-02-15 06:05:18
Size: 3263
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

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 the state in 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.

      The entry point for the Albatross application is usually in a file called app.cgi. It acts as the state machine controller and is the destination of CGI requests. It reads the request, sets up the session context, and then passes the request and the session context to the handler.

      The initial state for the state machine is passed to the application's contructor which is used when there isn't an active session; when it already exists it is loaded along with the rest of the session's context. The session is stored on the server by the al-session-manager process.

  • 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 by 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)