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
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.
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.
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.
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
- Introduction to Cloud Computing (Salesforce.com and Force.com)
- Overview of Database Concepts (Salesforce.com)
- Introduction to Force.com
- Building Salesforce Custom App and Objects
- Object Relationships and Formula Field in Salesforce
- Salesforce Security Model and Overview
- Automation in Salesforce
- Approval Process in Salesforce
- Introduction to SOQL and SOSL
- Introduction to Apex
- Salesforce Data Management
- Visualforce MVC Architecture on Cloud
- Salesforce Reports and Dashboards
- Building a Visualforce (Custom) Page for the Salesforce App
- Salesforce Sandbox and Overview of Force.com capabilities
- Learning Apex and Deployment Tools