Apr 30, 2019 | 0 Comment | Posted by Shrey Sharma

MVC Architecture in Salesforce

 

Model View Controller (MVC Architecture in Salesforce) is a software pattern that separates the representation of information from the user’s interaction with it.

SFDC MVC:

 

  • We can write our VIEW pages using SFDC visual force (VF pages).
  • Each VF page is associated with a Controller.
  • We can make use of already built Standard controllers or we can write our own controller using Apex language. Apex is OO and very much similar to JAVA.
  • We can also write Model Classes using Apex.

 

MVC architecture in Salesforce pattern contains below three modules:

Model (Database Layer):

The schema and data salesforce use to represent the system completely. In Salesforce, we can say that sObjects are the model as every entity in salesforce is mapped to some sObject. (sObjects are any objects that can be stored in the Force.com platform database)

 

View (User Interface Layer):

How the schema and data are represented. Visualforce is used to present the data to users.

 

Controller (Business Logic Layer):

How the interface actions. Controllers are used to perform the actions whenever users interact with visual force.

 

In SFDC:

  • Visual Force pages, Page Layouts, Tabs comes under View Layer of Model View Controller in Salesforce.
  • Workflows, Apex Classes, Triggers comes under Controller part in Model View controller in Salesforce.
  • Objects, Fields, Relationships come under Model Layer of Model View Controller in Salesforce.

 

Benefits of using MVC Architecture in Salesforce:

 

Reliability: 

The layers have clear separation so it allows greater reliability if we want to change any layer. For example, if can change the look and feel of an application without recompiling Model or Controller code.

 

High Reuse and adaptability:

MVC provides multiple types of views all accessing the same code.

 

Very low development and life cycle cost: 

It makes it possible to have lower-level programmers develop and maintain user interfaces. Development time can be significantly reduced because Controller programmers focus solely on transactions and view programmers focus solely on presentation.

 

Easy to maintain: 

The separation between layers makes it easier to maintain, test, and deploy apps.

 

Share This Post

Leave a Comment

Your email address will not be published. Required fields are marked *

-->