Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Apex Design Patterns

You're reading from  Apex Design Patterns

Product type Book
Published in Apr 2016
Publisher
ISBN-13 9781782173656
Pages 256 pages
Edition 1st Edition
Languages
Authors (2):
Anshul Verma Anshul Verma
Profile icon Anshul Verma
Jitendra Zaa Jitendra Zaa
Profile icon Jitendra Zaa
View More author details

The singleton pattern


The singleton design pattern restricts the instantiation of a class to only one object.

This is a useful design pattern in Apex and is frequently used. As discussed in the previous chapter, Salesforce has various governor limits; for example, a number of SOQL queries, a number of query rows returned, and a number of DML operations that can be performed in a single request.

Using the singleton design pattern, we can make sure that utility classes are instantiated only once, which can help in avoiding governor limits.

The sales division of a call center receives calls either from a customer or broker who is interested in the product. If a call comes directly from a customer, then the call center agents need to create a new opportunity record with all the required information. Alternatively, if a call comes from a broker, then the call center agents need to create an opportunity record and then record it for a broker as well. Brokers are eligible for commission if they sell...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}