MVC Architecture
What is the architecture of Salesforce and Salesforce Lightning?
Ans: Salesforce MVC architecture helps to develop powerful business application. Everything we develop in Salesforce is part of Model View Controller. Salesforce follows MVC(Model, View, Controller) architecture, here
- Model means, Where we can store data. In Salesofrce for storing data we have Objects, Custom settings and Custom Metadata types. The schema and data salesforce use to represent the system completely. In Salesforce, we can say that sObjects are the model as every entity in salesforce is mapped to some sObject. (sObjects are any objects that can be stored in the Force.com platform database)
- View means, How the information is displayed to the user. We have PageLayouts, Visualforce Pages, Lightning Page and Lightning web pages.
- Controller means, How the data is going to process, We have workflows, Process Builder, Apex and Triggers.
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.
- Object Creation is part of “Model”.
- Visualforce page is part of “View” and
- Controller is a part of “Controller”.
In SFDC
1. Visual Force pages, Page Layouts, Tabs comes under View Layer of Model View controller .
2. Workflows, Apex Classes, Triggers comes under Controller part in Model View controller .
3. Objects, Fields, Relationships comes under Model Layer of Model View Controller .
* Salesforce Lightning follows MVCC architecture
- Model, View, Controller, Controller
- Controller: One controller is javaScript controller(Client side) to communicate with view.
- Controller: Another controller is Apex controller(Server side) to communicate with model.
Benefits of using MVC Architecture in Salesforce:
Reliability:
The layers have clear separation so it allows greater reliability if we want to change any layer. For example, if can change the look and feel of an application without recompiling Model or Controller code.
High Reuse and adaptability:
MVC provides multiple types of views all accessing the same code.
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 solely on presentation.
Easy to maintain:
The separation between layers makes it easier to maintain, test, and deploy apps.
No comments:
Post a Comment