Object-oriented programming in Apex
Apex is a fully featured object-oriented programming language that enables developers to utilize features such as inheritance, polymorphism, abstraction, and encapsulation in order to develop applications in a way that is easy to manage, scale, and test. It is often the case that the first introduction to Apex that many developers get is through a trigger, which, by nature, is a very linear structure for organizing code. A trigger will run from the first line to the last in order and does not have any of the standard OOP capabilities; triggers cannot implement an interface or extend any classes. Although it is a best practice to extract the logic within a trigger to a set of classes and methods, as we saw in Chapter 3, Triggers and Managing Trigger Execution, it is not a requirement to do so, and many triggers are still written that do not follow this best practice.
Many developers do not start to work with the object-oriented capabilities of...