Salesforce Platform Developer I (legacy) — Question 232
Which two strategies should a developer use to avoid hitting governor limits when developing in a multi-tenant environment? (Choose two.)
Answer options
- A. Use collections to store all fields from a related object and not just minimally required fields.
- B. Use methods from the ג€Limitsג€ class to monitor governor limits.
- C. Use SOQL for loops to iterate data retrieved from queries that return a high number of rows.
- D. Use variables within Apex classes to store large amounts of data.
Correct answer: B, C
Explanation
Choosing option B is correct because using the 'Limits' class allows developers to monitor their usage and avoid hitting governor limits. Option C is also correct as SOQL for loops help manage memory consumption by processing records in manageable chunks. Options A and D are incorrect because they can lead to exceeding governor limits by storing unnecessary data and using excessive memory, respectively.