MVC is one of the widely used software architecture design pattern which divide the design in three basic components i.e. Model, View and Controller. Salesforce provides Visualforce an interface to quickly develop applications following MVC architecture over the cloud.
In Visualforce you can implement MVC using 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 need. Each View has associated controller. Developer can use some standard controller 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 support any custom objects created as per customer requirement. What kind of schema should be use and what kind of data should be use to represent that is decided here. We can consider the example of sObjects as Model in saleforce. As every entity is mapped to some sObjects.
Field, Object and Relationships come under the Model section of MVC architecture.
The presentation of information to the user is nothing but the View. This is one user interface given to user for interaction with system. View consists of visual salesforce pages and components. Pages may be linked with Visual force components. These pages use HTML for preparing layout of application. To refer each page it is linked with unique URL similar to web pages.
Components – The reusable code or block of code is named as 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.
The 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 controller using components. Salesforce has 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 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 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