Apex Design Patterns: The Singleton Pattern in Salesforce

Credits : Amit Singh

The Singleton Pattern

  1. 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
  2. One private constructor will have the logic for reusable code. For example, a SOQL Query
  3. One public static method which will return the instance of that class
  4. Other private variables to store the information such as record type id or complete sObject record.


Popular Salesforce Videos