官术网_书友最值得收藏!

The MVC paradigm

MVC is an architectural design pattern in modern software development that promotes the separation of an application into three components:

  • An application's data storage (model)
  • An application's user interface (view)
  • An application's logic (controller)

The following diagram maps Salesforce's components to this architectural design:

This architecture is used a lot in software development because the isolation of data (that is, the model), user interface (that is, the view), and logic (that is, the controller) allows each component to be developed, tested, and maintained independently.

  • Model: This is actually where your data is stored and can be used. To store data, you need objects or fields, and these are considered to be part of the model.
  • View: This is whatever end users see and interact with; that is, what displays data to the clients or customers. This allows you to control how (and what) data is shown on the user interface. So, standard pages, page layouts, Visualforce pages, Lightning components, console layouts, and mini page layouts are all considered part of the view.
  • Controller: This refers to the actual logic and actions that are executed when someone interacts with Visualforce pages, standard pages, or Lightning components. The controller is the link that binds the client side and the server side. It will mostly consist of Apex; this means that even when building Lightning components, you'll probably need Apex to get the data from the database on the server and pass it to the JavaScript controller. The new Lightning Data Service from Salesforce acts like a standard controller—it connects to objects and fields in the database without writing any Apex.

You could describe MVC like this—when you see a registration form (such as the Visualforce page developed on Salesforce), enter some information into the form, and then hit submit, the details are sent to a database and are saved into tables, columns, and rows (these are Salesforce objects and fields). Which data goes to what object and field in Salesforce is controlled by the logic defined in the standard and custom controllers.

主站蜘蛛池模板: 阳春市| 原平市| 南华县| 苍山县| 南充市| 桐城市| 内丘县| 资溪县| 浪卡子县| 渭南市| 东宁县| 山西省| 阳高县| 平江县| 新干县| 蒲城县| 沈丘县| 栾城县| 桂林市| 镇原县| 海晏县| 四平市| 迁西县| 同江市| 平昌县| 改则县| 平度市| 高平市| 邳州市| 尉氏县| 宾川县| 六安市| 张家口市| 岐山县| 吴旗县| 富平县| 隆林| 铁岭县| 福海县| 尉犁县| 五指山市|