Book Image

Learning Apex Programming

Book Image

Learning Apex Programming

Overview of this book

Table of Contents (17 chapters)
Learning Apex Programming
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Class is in session


As we mentioned before, when we write triggers, the majority of code goes into our Apex classes, not the triggers themselves. As only the platform can execute the code in a trigger, any code you put in there is inaccessible to you. This means that if you ever need to reuse the same logic, you'd have to rewrite it in a class. If you're going to have it rewritten anyway, you might as well just start off correctly and put it in a class to begin with.

We can create a new Apex class from the Force.com IDE as follows:

  1. Right-click on your project in the Force.com IDE and navigate to New | Apex Class.

    The Create New Apex Trigger window appears as shown:

  2. Enter the name for your new Apex class. For this example, use accountMethods.

  3. Leave the Template option as Default.

  4. Click on the Finish button.

    A progress bar will appear followed by your new Apex class.

Currently, there are only three template options available when creating a new Apex class from the Force.com IDE:

  • Default: This is an...