2
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.

7

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.

Reference

| improve this answer | |
2

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

| improve this answer | |
  • 4
    Singleton is generally used when you want a single instance of a class rather than a property value. – Robs Jan 8 '19 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.