The following Apex method is part of the ContactService class that is called from a trigger:

How should the developer modify the code to ensure best practices are met?
A)


C)

D)
Suggested Answer: A
Get Premium DEX-450 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
14 comments · newest first
NA
Nada
10 months ago
Wait, why are we even considering Option B?
CR
Crissy
11 months ago
Not sure about Option D, seems risky.
RE
Rebecka
11 months ago
I think Option A has some merit too.
AL
Alline
11 months ago
Option C is definitely the best choice here.
LE
Leatha
11 months ago
Really? I didn't expect Option C to be the best.
VA
Val
11 months ago
I think we practiced a similar question where we had to ensure that the method was static. I wonder if that applies here too.
PE
Percy
12 months ago
I feel like one of the options might involve using a Map instead of a List to optimize performance, but I can't recall which one.
JE
Jerrod
12 months ago
I'm not entirely sure, but I think we might need to check for governor limits in this method. That seems to come up a lot in practice questions.
TA
Tayna
1 year ago
I remember we discussed the importance of bulkification in triggers, so I think that might be a key point here.
NA
Nathalie
1 year ago
Ah, I see what they're getting at. Option C is the way to go - it avoids the unnecessary SOQL query and updates the contact record in a single transaction.
AR
Ariel
1 year ago
I'm a bit unsure about this one. I'll need to double-check the Apex best practices to make sure I'm selecting the right option.
YU
Yuki
1 year ago
Option A looks good to me - it removes the unnecessary SOQL query and updates the contact record directly. That seems like the most efficient approach.
DE
Deeanna
1 year ago
Hmm, the code seems a bit complex. I'll need to think through the implications of each option to make sure I understand the best practice.
XU
Xuan
1 year ago
This looks like a pretty straightforward question. I'll carefully review the code and options to identify the best practice approach.