Book Image

Visualforce Developer's guide

By : Chamil Madusanka
Book Image

Visualforce Developer's guide

By: Chamil Madusanka

Overview of this book

<p>Visualforce allows you to build sophisticated, custom user interfaces that can be hosted natively on the Force.com platform. Visualforce achieves this with the help of a tag-based language which is similar to HTML. This book aims to introduce you to Visualforce development tools to develop a better perspective towards UI development with Visualforce, and take your expertise in UI development to the next level.</p> <p>"Visualforce Developer's Guide" is a hands-on guide aimed towards developing a custom UI interface. As you read through the content, you will notice that this book focuses on a single real-world example. This book builds upon this example to help you understand and use Visualforce development tools in your custom UI interfaces.</p> <p>"Visualforce Developer's Guide" begins with an introduction to Visualforce to give you an understanding of the MVC model and the Visualforce architecture. Special emphasis is given to building a rich user interface by leveraging JavaScript, jQuery, CSS, and HTML with Visualforce. Through the course of the book, you will learn how to reuse the code with the help of custom components, and minimize the Visualforce and Apex code through Visualforce dynamic binding. The later sections of the book focus on building Visualforce pages for mobile devices. By the end of the book, you will learn the best practices and security tips for Apex and Visualforce development.</p>
Table of Contents (17 chapters)
Visualforce Developer's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 of Apex.