Apex Design Patterns: The Singleton Pattern in Salesforce
The Singleton Pattern
- One Private variable of the class itself will hold the instance of the complete class so that we can access all the private and public variables inside that class
- One private constructor will have the logic for reusable code. For example, a SOQL Query
- One public static method which will return the instance of that class
- Other private variables to store the information such as record type id or complete sObject record.