Free Salesforce Admin Tutorial >

Chapter 13 - MVC Architecture >

MVC Architecture in Salesforce

MVC Architecture in Salesforce

What You’ll Learn

S2 Labs

Ever wonder how Salesforce organizes things? Look at the Model-View-Controller (MVC) architecture in Salesforce. Here’s the gist: the Model handles your data (think leads, contacts, opportunities), the View crafts what users see (web pages, reports), and the Controller manages user interactions (button clicks, form submissions).

This separation keeps things clean, efficient, and easier to maintain, ensuring a smooth Salesforce experience for everyone. Let’s explore this architecture.

What is MVC Architecture in Salesforce?

Model-view-controller (MVC) Architecture in Salesforce is a software pattern that separates information representation from user interaction. It divides the application into three manageable parts. 

Salesforce MVC Architecture

Modules in Salesforce MVC Architecture

The Salesforce MVC architecture pattern contains three modules:

Implementation Of Salesforce MVC Architecture

1. Model (Database Layer)

The schema and data in Salesforce represent the system altogether. Salesforce objects, known as sObjects, serve as the Model in the Model-View-Controller (MVC) architecture.

Each entity in Salesforce is mapped to an sObject, which can be any object that can be stored in the Salesforce platform database. It is a data model for all the objects, which helps us understand the relationship between them and each of their fields.

2. View (User Interface Layer)

The view layer is the UI and controls the schema representation and data. It uses Visualforce to present the data to users, enabling them to modify it. It also determines how the UI will look.

3. Controller (Business Logic Layer)

Controllers perform actions whenever users interact with Visual Force. They contain all the business logic, such as APEX classes, that help us communicate with the database from the UI. The Controller transfers a command to the Model to update itself. 


  1. Visual Force pages, Page Layouts, and Tabs are part of the View Layer of Model View Controller in Salesforce.
  2. Workflows, Apex Classes, and Triggers come under the Controller part in the Model View Controller in Salesforce.
  3. Objects, Fields, and Relationships come under the Model Layer of the Model View Controller in Salesforce.

How Does the Salesforce MVC Architecture Work?

Any request for an application in SFDC goes through a process in the Salesforce MVC Architecture. The following are the steps : 

  1. First, the user will request the view.
  2. The view generates the user interface,
  3. Once the request reaches the controller, the route configuration is checked.
  4. After checking the configuration, the request is passed on to the Model for further checking.
  5. The Model processes the request and generates a response, which is then passed back to the controller.
  6. Once the result is generated, it will upload to view through the view engine.

Features Of Salesforce MVC Architecture

Here are some of the features of Salesforce

  • We can write our VIEW pages using SFDC visual force (VF pages).
  • Each VF page is associated with a Controller.
  • We can use already-built Standard controllers(like Account, Contact, etc.) or write our Controller using Apex. Apex is object-oriented (Salesforce’s proprietary Language) and similar to Java.
  • We can also write Model Classes using Apex.

Benefits of Using Salesforce MVC Architecture 

Some benefits of the Salesforce Model View Controller Architecture are given below:

1. Reliability

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

2. High Reuse and Adaptability

MVC provides multiple types of views, all accessing the same code, which makes it adaptable for new users. 

3. 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 exclusively on presentation.

4. Easy to Maintain

The separation between layers makes it easier to maintain, test, and deploy apps with the help of the MVC Architecture in Salesforce.

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

  • Qaznardevolo 21 Mar, 2023 at 1:40 pm

    interesting for a very long time

  • Qazzyirome 25 Mar, 2023 at 10:22 pm

    Thanks, I’ve been looking for this for a long time

Post a Comment

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