Español Español English English Français
The WebAbility® Network

The WebAbility®
Network

Enter the Web Effect

Documentación WebAbility® Network [Página principal]
The Box Model Pattern: ( /Box/reference/BoxModel )

I. Understanding the box model


Anything in life, and more a programming language, or a system design, can be represented as a flow of precise tasks to execute.

The box model is based on this principle to explode a bigger task (also called a process, a goal, or a function) into smaller tasks with some rules on how to interconnect the tasks.

When we analyze the smaller tasks of a lot of functions, we immediatly realize that 90% of those tasks are the same basic tasks reused many times.

Let's take a simple example:

We are building a system with 3 defined functions:
1 - Show a press room
2 - Show a single article in the press room
3 - Show a catalog of products to buy

1. The press room function can be exploded in those single tasks:
- Gets the quantity of articles in the press room
- Calculates the quantity of possible pages
- Gets the data of the articles that are into the current page
- Loops on the articles to paint each one of them
- Integrates the painted articles into a matrix
- Integrates the matrix, the pagination, and other things into the template of the page

2. The single article can be exploded in those single tasks:
- Gets the data of the article
- Integrates the data into the template of the page

3. The catalog of products can be exploded in those single tasks:
- Gets the quantity of products to show in the asked classification
- Calculates the quantity of possible pages
- Gets the products data of the current page
- Loops on the products to paint each one of them
- Integrates the painted products into a matrix
- Integrates the matrix, the pagination, and other things into the template of the page


What we immediatly see, is there are some repetitive tasks that are the same between the functions.
- Calculates the quantity of possible pages
- Loops on the products/articles to paint each one of them
- Integrates the data into the template of the page
for instance.

The basic tasks between the functions are mainly the same, let's say, based on some parameters that
could change the behaviour of the generic task.

Applied to the construction of a web application, we can resume 90% of the code you generate to some 6 basic tasks

II. So what is a box?


We are going to call a Box every basic tasks we can use to represent the flow of a function.

A box has from 0 to the quantity you need of inputs, and from 1 to the quantity you need of outputs.
What happens in the box is a preprogrammed behaviour, that will transform the inputs into the outputs.

A box is a transformer class, that will process the inputs into the outputs.

There are 6 well-known types of inputs and outputs for the basic boxes:

Scalar values
Template instance (the object itself, a string with the template or a path to the template file)
Language instance (the object itself, a string containing the XML definition or a path to the XML definition file)
Vector of scalar values
Vector of vectors
Vector of templates

III. The box flow






[Ver la página] [Modificar] [Archivos multimedia] [Bitácora de cambios] [Seguridad] [Borrar esta página] [Cambiar el ID] [Herramientas]












WebAbility®, © 2000-2012 Philippe Thomassigny - Algunos derechos reservados