Summary
In this chapter, you’ve learned a new way to factor business logic beyond encapsulating it in the Service layer—one that aligns the logic—implementing the validation changes and interpretation of an object’s data through Domain classes named accordingly. We explored two ways to factor your Domain logic by either combining Apex Trigger-related logic and Domain logic into one class, using the CDCL convention, or splitting them into two classes using the SDCL convention. As with the Service layer, this approach makes such code easy to find for new and experienced developers working on the code base.
A Domain class combines the traditional Apex Trigger logic and custom Domain logic, such as the calculation of championship points for a contestant or the verification of compliance rules against the cars, drivers, and teams.
By utilizing Apex classes, the ability to start leveraging OOP practices emerges, using interfaces and factory methods to...