<ctpp/> home .:. download .:. documentation .:. faq  
o Home
    Download!
    Installation

o Help
    What is the CTPP library?
    How it works?
    Online documentation
    FAQ

o In action
    Projects
    First steps
    HOWTOs..
    Development

o In deveopment
    Schedule
    Credits




How does CTPP2 work?

MVC paradigm

The MVC paradigm divides an application into three basic entities: a set of Models, a Controller, and the View.

A classic implementation completely isolates these entities from each other. It is assumed that a View doesnt process any data and only renders a corresponding object model according to the template, that a Controller is only used to determine the list of executed models, and that Models represent entirely abstract data sets and rules that govern the data.

This paradigm allows separating the functions of a web designer, a programmer and a manager. A lot of the code can be reused. In addition a project has a single entry point which facilitates its upgrading and development.

MVC flaws and their remedies

As the load on the system grows, the overhead of communication between the abstraction layers grows as well and at some point the classic MVC paradigm stops working. At least, it doesnt work without a significant increase in the hardware capacity. High load projects often require purchasing dozens of new computers when the computational throughput grows by 20-30%. It is clear that this approach is deficient and the solution has to be less resource intensive.

It would be logical to enhance the MVC paradigm so that information is partially processed at the View level. Namely, the main data set is still maintained by the Models but the final calculation for the output happens in a special block the Data Processor.

A Data processor, is part of a View, performs simple data manipulations immediately before the output to the UI. For example, formatting the date given as a Unix timestamp integer value to a "dd-mm-yyyy" string.

Architecture of CTPP

As represented in the diagram below the architecture of the template engine consists of 4 subsystems: a template compiler which converts the text of the page template into bytecode, a virtual machine which executes the bytecode, a caching system for templates, and a library of data processor functions.


Why did we choose to include a virtual machine and a compiler in the architecture? This way some code can be implemented once and for all and as the syntax of templates grows in complexity, the library of View functions doesnt need to be redesigned. The compiled code (bytecode) requires only that the objects it needs for execution are loaded into memory. In addition, bytecode can be easily cached and shared between processes. Moreover, some rarely modified templates can be stored as binaries thus significantly improving the performance of the system.


Copyright © 2003 - 2008 CTPP Dev Team.