Study for the Salesforce Platform Developer Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Practice this question and more.


When would a developer use a custom controller instead of a controller extension?

  1. When a Visualforce page needs to replace the functionality of a standard controller.

  2. When a Visualforce page does not reference a single primary object.

  3. When a Visualforce page should not enforce permissions or field-level security.

  4. When a Visualforce page needs to add new actions to a standard controller.

The correct answer is: When a Visualforce page needs to replace the functionality of a standard controller.

A developer would opt for a custom controller when a Visualforce page is designed to completely replace the functionality of a standard controller. Custom controllers offer complete control over the behavior of the page as they are built from scratch. This is particularly useful in scenarios where the developer needs to customize the interactions and data handling beyond what is provided by standard controllers. In cases where the Visualforce page needs to replace all default actions and logic provided by a standard controller, a custom controller is essential. This allows the developer to implement unique logic and manage data in a way that aligns with specific business requirements without being limited by the constraints of the standard controller. The other choices hint at scenarios where different approaches should be considered. A controller extension is usually preferred when you want to build upon the functionality of an existing standard controller by adding new features or methods while maintaining the standard features. Choosing a custom controller means the developer is looking for a fresh start rather than extending existing behavior.