Architecture
LiveCart code is structured into a Model-View-Controller (MVC) architecture, which means that the application is basically structured into three distinct layers that provide separation of presentation logic, business logic and data:
-
Model - represents business entities: products, categories, orders, users, etc. - and provides means to access and manipulate object data. LiveCart model classes implement Active Record pattern, which allows to completely abstract the database operations.
-
View - generates application output. In LiveCart views are simply Smarty templates.
-
Controller - works as a glue between a model and a view and defines application behavior. In essence, main controller responsibilities are to read/change model state and pass model data to view for displaying.
Such architecture allows to achieve a great code separation by responsibility, which provides several additional benefits:
-
Enforces clean and organized code structure.
-
Easy to make changes - one doesn't even need to touch business or model logic code when it's only necessary to modify the presentation template.
-
Different methods of presentation for the same data are possible (just change the view to return data in XML, for example).
-
Possible to extend application behavior without a need to change Controller code. The Controller passes the data to View through an intermediary Response object, which can be altered before it reaches the View.