public static List<Holiday> holidays {
        get {
            if(holidays == null)
                holidays=[Select h.StartTimeInMinutes, h.Name, h.ActivityDate From Holiday h];
            return holidays;
        private set;

Reference links if possible.


2 Answers 2


It's called Lazy Loading or Lazy initialization

Lazy loading is a design pattern to defer initialization until the point at which it is needed.



Well its combination of few, As Robs mentioned its caled lazy loading. Also Its called as Singleton Pattern.

Singleton pattern makes sure, you have a single instance of a particular instancein the whole transaction(in your case holidays).

Src: https://developer.salesforce.com/page/Apex_Design_Patterns_-_Singleton

  • 4
    Singleton is generally used when you want a single instance of a class rather than a property value.
    – Robs
    Commented Jan 8, 2019 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .