O'Reilly logo

Visualforce Developer's Guide by W.A.Chamil Madusanka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controllers and controller extensions

When we are developing controllers and controller extensions that are associated to Visualforce pages, we need to adhere to the following best practices:

  • By using the with sharing keyword, we can enforce the sharing rules in controllers. Then the code will execute in the user mode instead of the system mode.
  • We must not depend on the setter method to be executed before the constructor.
  • We must not depend on the execution order or side effects while creating custom methods in a custom controller or a controller extension.
  • Do not use DML operations inside a loop.
  • While performing record filtering, add filters in the following order:
    • In SOQL
    • In Apex
    • In Visualforce
  • If possible, calculations must be performed in SOQL instead ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required