Salesforce Certified Platform Developer II — Question 241
Universal Containers (UC) calculates commissions on their Opportunities in different ways base on complex rules that vary depending on the line of business of the Opportunity.
Whenever a new line of business is added to Salesforce at UC, it is likely that a different calculation will need to be added too. When an Opportunity's stage is changed to Closed/Won, its commission should be calculated in real time.
What should a developer use so that different implementations of the commission calculation can be invoked on the stage change?
Answer options
- A. An Apex class with a custom enum
- B. A final class with multiple methods
- C. An interface and implementing classes
- D. Apex Describe Schema methods
Correct answer: C
Explanation
The correct answer is C, as using an interface along with implementing classes allows for different commission calculation methods to be easily defined and invoked based on the specific business line. This approach supports polymorphism, enabling the developer to add new calculations without altering existing code. The other options do not provide the same flexibility or scalability for handling multiple commission calculations.