When starting to write Apex, it is tempting to start with an Apex Trigger or Apex Controller class and to start placing the required logic in those classes to implement the desired functionality. This chapter will explore a different starting point; one that allows the developer to focus on writing application business logic (the core logic of your application) in a way that is independent of the calling context. It will also explain the benefits that it brings in terms of reuse, code maintainability, and flexibility, especially when applying code to different areas of the platform.
We will explore the ways in which Apex code can be invoked, the requirements and benefits of those contexts, their commonalities, their differences, and the best practices that are shared. We will distill these into a layered way of writing code that teaches...