Staying classy

Whether you are implementing a built-in interface, controlling a Visualforce page, or facilitating a trigger logic, classes are the solution. While classes are often used as templates for objects that you construct, most of the examples we've shown so far leverage static methods in these classes. It's actually a best practice to call static methods stored in classes from your triggers, as they are more efficient on the server. There are times though where you want to do more than just call a single method, so let's take a look at some more complex functionality in classes.

When you plan on instantiating your class as an object, you often want to set some default values. If you are going to create multiple instances of this object, ...

Get Learning Apex Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.