Salesforce Tutorial# 12: Salesforce MVC Architecture on Cloud

Salesforce MVC Architecture is one of the widely used software architecture design patterns which divides the design into three basic components i.e. Model, View, and Controller. Salesforce provides Visualforce an interface to quickly develop applications following MVC architecture over the cloud.

Salesforce MVC Architecture

In Visualforce you can implement MVC using the standard as well as custom objects. Also, you can implement MVC using 3 newly introduced Salesforce objects pages, components, and controllers.

These pages work like JSP or ASP pages and give the best presentation as per user needs. Each View has an associated controller. Developers can use some standard controllers or can write their own using Apex programming language.  VF also has auto-generated controllers to make interaction with databases.

Fig 12.1 MVC architecture

MODEL

The database objects in Salesforce are known as Data Model. It consists of the standard Salesforce objects like Accounts, Contacts, Opportunities, and Leads, etc. It also supports any custom objects created as per customer requirements. What kind of schema should be use and what kind of data should be used to represent that is decided here. We can consider the example of sObjects as Model in salesforce. As every entity is mapped to some sObjects.

Field, Object, and Relationships come under the Model section of MVC salesforce architecture.

VIEW

The presentation of information to the user is nothing but the View. This is one user interface given to the user for interaction with the system.  A view consists of visual salesforce pages and components. Pages may be linked with Visual force components. These pages use HTML for preparing the layout of the application. To refer to each page it is linked with a unique URL similar to web pages.

Components – The reusable code or block of code is named as a component. These components can be styled with CSS and are reused whenever necessary.

Visual force pages, tabs and Page layout classes come under the View.

CONTROLLER

Business logic is implemented in controller. These are the building blocks of the actual logic using Apex language. The pages from the view interact with the controller using components. Salesforce has a pre-build controller for some standard actions like save, Edit, etc. Workflow, Triggers, and Apex classes comes under this layer.

salesforce mvc architecture

Fig 12.2 Salesforce MVC Pattern Ref: http://www.salesforcegeneral.com/salesforce-mvc-explained/

This is a basic introduction to Visualforce MVC and how it is an integral part of Salesforce. Please stay tuned for more informative articles on Salesforce.

If you need to refer other Salesforce related information please feel free to navigate using below an index

Tutorial Index

  1. Introduction to Cloud Computing (Salesforce.com and Force.com)
  2. Overview of Database Concepts (Salesforce.com)
  3. Introduction to Force.com
  4. Building Salesforce Custom App and Objects
  5. Object Relationships and Formula Field in Salesforce
  6. Salesforce Security Model and Overview
  7. Automation in Salesforce
  8. Approval Process in Salesforce
  9. Introduction to SOQL and SOSL
  10. Introduction to Apex
  11. Salesforce Data Management
  12. Visualforce MVC Architecture on Cloud
  13. Salesforce Reports and Dashboards
  14. Building a Visualforce (Custom) Page for the Salesforce App
  15. Salesforce Sandbox and Overview of Force.com capabilities
  16. Learning Apex and Deployment Tools

Add a Comment

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