Salesforce MVC (Model view Controller) separates the complexity of the business logic from the User Interface and database. Salesforce MVC architecture helps to develop powerful business application. Everything we develop in Salesforce is part of Model View Controller.

Salesforce MVC architecture with an Example.

It is very important to understand about the flow of the project when working with Sfdc MVC architecture. Everything we develop in Salesforce is a part of Model View Controller. Developed application in Salesforce is divided into three kinds of components, SFDC MVC design defines the interaction between them.

Example :- When a custom object is created in Salesforce and a visualforce page is created to display the details of the record of the custom object using controller. In this Scenario, we observe three parts Object creation, Visualforce page and Controller.

  1. Object Creation is part of “Model”.
  2. Visualforce page is part of “View” and
  3. Controller is a part of “Controller”.
Salesforce MVC Architecture - Model View Controller (MVC)

SFDC Model View Controller (MVC).

So Model View Controller (MVC) is a software architecture pattern which separated the representation of information from the user’s interaction. So anything displayed to user is a part of view, business logics/implementation is a part of controller and tables in salesforce is part of Model.

  • Model : Model or the database is the backbone which forms the bridge between View and Controller. Data is wrapped in the model and send to the User Interface for display. The metadata, Salesforce objects, Apex Objects and schema forms the model layer.
  • View :- Every time we will get a different page view when we click on the page. For every click the page will give us two page views. uses Visualforce pages, sites and standard UI buttons, forms, tabs and page views to define a view.
  • Controller :- Every event performed on the page will be controlled by controller. uses workflows, Apex triggers and Apex Controllers as the controller in the  Salesforce MVC architecture.

When we click on the page, Application, Object, Fields, Tabs some action is going to perform. Here buttons, Tabs are the controllers. It controls and fetch records from the Database and give to the view.

Development in Salesforce can be done in two ways: One is point-and-click with out using single line of code which is known as declarative programming and the second method is developing application using code, known as Programmatic development.

Declarative development in Salesforce.

Declarative development in Salesforce is done by point-and-click with out using single line of code using browser. In this method, Salesforce follows MVC Architecture when developing application.

ObjectsApplicationsWorkflow Rules
FieldsTabsValidation Rules
RelationshipsPage LayoutsAssignment Rule
Records Types

Programmatic development in Salesforce.

In this model of development in Salesforce, Salesforce coding is required. The Salesforce MVC architecture are as follows.

Web Services APIVisualforce PagesApex Controllers
Metadata APIVisualforce ComponentsApex Trigger
External ObjectSiteWeb Service API