Library/Patterns/Model-View-Controller

Model maintains the actual data and how to manipulate that data. Controller tells what needs to be done. View presents a user-centric perspective of the model and ways to invoke other views or controller actions.

MVC
In LxEngine, the Model is the Document and it's Elements. In tradition database MVC setups, the Model is the database tables and the rows of that table. In LxEngine, the Model is set up in a tree structure of Elements with a single tree per Document. The Model itself contains the actual data and knows how to manipulate that data.

The Controller is essentially translates high-level user or application actions into low-level Model operations. It decides what is happening, with the low-level implementation of that what being handled by the Model. For example, a Controller might add a "highlight" command for an Element or set of Elements. This Controller would invoke the necessary attribute changes on the Model to indicate a temporary style change on that data.

The View is essentially a query on a subset of the Model that presents the results of that query to the user in some form or another, as well as provides the ability to invoke Controllers on the data via UI events. The View reads data from the Model, presents it, and maps UI events into Controller invokations.

Indices
An important addition is 'Index objects. These are recreatable objects that provide special kinds of queries on the Model, usually with performance in mind. For example, a spatial index is likely optimized to handle frusta-based queries on the Model. The Index usually works by attaching to the Model and updating its internal caches as operations are applied to the Model. The Index has a one-way, read-only relationship with the Model. The Model itself only pushes event notification to the Index but does not modify it.

Comparison to traditional ORM
When compared to traditional object-relational mapping, LxEngine works differently. In normal ORM, a database table maps to an object class and a row in that table maps to an instance of that object. However, LxEngine is based on a tree of Elements. In LxEngine, each Element type maps to a class or classes of run-time objects - each mapping can create a Component that is attached to the Element. Each Element itself maps to a particular object, which may have zero or more attached objects.