Chapter 2. Creational Patterns
Apex programming revolves around objects and classes. During the course of application development, we create multiple classes. Also, we create objects of these classes to satisfy business requirements. Creating an object of a class within another class, creates dependency between those classes. This is also known as tight coupling.
As discussed in the previous chapter, tight coupling is considered inferior, as it can negatively impact the code's maintainability and scalability. Creational design patterns can help us avoid tight coupling by hiding the object creational logic.
Creational design patterns can be considered in the following scenarios:
- Instantiating classes in the Apex
Scheduler
class. If we directly instantiate the Apex class in scheduler using new keyword, then the class gets serialized and, therefore, locked for further changes. - Using multiple classes while creating test data in test classes.
- Creating code libraries only...