MVC Architecture in Salesforce  : In our previous salesforce tutorial we have learned about Visualforce page basic and in this salesforce training tutorial we are going to learn about Salesforce MVC Architecture.

What is salesforce MVC Architecture ?

Full form for MVC is Model-View-Controller. MVC architecture technology is used by force.com platform to develop many applications using visualforce. MVC architecture is a prevalent architectural design pattern in modern software development which promotes application’s logic, user interface and data storage. Force.com architecture is convenient and fit within the MVC Architecture.

salesforce mvc architecture

 salesforce mvc architecture

From above Salesforce MVC architecture we can find three major components they are

  • Model component.
  • View component.
  • Controller component.

Model Component

In model component we will have standard object and custom objects. This is also called data model. This model components defines the structure of the data i.e here we are having custom and standard objects.

View Component.

This view component defines how the data is represented. Visualforce pages, standard pages are the view  components. Page layouts are also comes under this components.

Controller Component.

Controller components defines the business logic. Here we have standard controller and custom controllers. Some of the components under this category are Apex classes, triggers, workflows, approvals and validation rules .

Example:- If we create a Visualforce page (the view) with a text field and a “Save” button. The text field holds your last name, and this is persisted in a custom object (the model). When the page loads the field on the view requests the stored first name value from the custom object; this communication happens via the page controller.”

Salesforce Model View Controller architecture separates the user interface layer which is called VIEW from the data layer called MODEL. Controller layer is between Model layer and View layer. This layer connects both View and Model. For example we have developed an application or document using Model view Controller architecture and any changes in that document will be seen as output in View(Out put representation layer).