The MVC Pattern

Model View Controller (The MVC Pattern)


  • An application data storage
  • Database software or the data
  • The underlying database
  • It’s the collection of Salesforce object and fields that we’d represent and modify in our page


  • Application user-interface
  • Look and feel, the user experience
  • In Visualforce
    • HTML, CSS, and Javascript code


  • Application logic, the middle layer between the model and the view
  • Takes data from the Model and presents it to the View
  • Takes input from the View and saves it to the Model
  • It’s the Apex code that interacts with the database according to the View’s needs
  • Controllers typically retrieve the data to be displayed in a page, takes input and saves it to the database. It contains code that executes in response to page actions, such as button being clicked


  • Three types of controllers:

    • Standard controllers
      • Canned, come with custom objects
    • Custom controllers
      • Need to code yourself
    • Controller extensions
      • Extensions that can be added on top of the Standard or Custom controllers
  • Why do we use MVC Pattern?

    • To separate our application into three different components to give us a module codebase
    • Easier to maintain and its scalable
    • Same reason we use Objects in SF
    • Also the same reason why we use classes in Apex

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: