Explore Interfaces and Implementations
Learning Objectives
After completing this unit, you’ll be able to:
- Describe the interface and implementation paradigm.
- List the different types of implementations an interface can have.
- Explain how Industries CPQ uses interfaces and implementations.
Before You Start
Before you start this module, make sure you complete the following content. The work you do here builds on the concepts and work you do in that content.
The Interface and Implementation Paradigm
The core of the Salesforce Industries open architecture is the interface and implementation paradigm. The Salesforce Industries Component Object Model (COM) delivers more than 60 interfaces and 100 implementations that provide an open, reusable, extensible, and modular approach. Sounds interesting? Before you explore further, learn about interfaces and implementations.
An interface is a call to business logic, and implementation is that business logic. The interface asks the question and the implementation provides the answer. For example, the pricing interface communicates with the system to determine the price of a product. The implementation responds with the rules to determine the correct price, with the business logic to evaluate the configuration and price lists.
The Right Tool for the Right Job
Salesforce Industries applications use interchangeable and reusable interfaces and implementations. You can customize the interfaces, replace them, or preserve your existing business logic. Salesforce offers multiple implementations for each interface. You can choose from any of the available implementations that best suit your needs or create your own. You can also create a hybrid solution that uses both Salesforce Industries and custom implementations. When used judiciously, you can define interfaces once and deploy them many times to consistently maintain and apply business logic.
Working with Interfaces and Implementations
Interface and implementation paradigms are central to the design of Industries Configure, Price, Quote (CPQ). The process of creating an order is a complex series of actions. At certain points in this process, Industries CPQ makes API calls to the appropriate interfaces to implement business logic using Apex classes.
Industries CPQ also uses interface implementations to leverage third-party or legacy code. For example, consider a legacy system that successfully implements a complex pricing structure. To use that process, you can call an interface implementation that links to and uses the existing process. You can also direct calls to several different pricing systems, depending on the input. All this and more is possible using interfaces and implementations.
Multiple Options for Each Interface
It’s time to understand how interfaces and implementations work together. Each interface and implementation has a trigger point. At the trigger point, you can call out to an external system and return information from that system. The implementation creates the output and sends it back to the interface.
Sometimes there are multiple implementations for one interface, but only one implementation can be active per interface. Your Salesforce admin switches on the correct implementation for your desired interface. Let's explore this in more detail.
Start by navigating to the Interface Implementations page in your Salesforce org.
- From the App Launcher, find and select Interface Implementations.
- On the Interface Implementations page, change the Recently Viewed list view to All.
- Search for and open the ProductValidationInterface.
Notice ProductValidationInterface’s multiple implementations.
[Alt text: ProductValidationInterface with multiple implementations.]
An implementation has two states: Active and Default. The Active implementation (1) is the implementation that the interface calls. The Default implementation (2) is the implementation that the interface calls when you don’t specify another implementation. In this case, the ValidationRulesImplementation (3) is both the active and the default implementation. You can also have multiple implementations for an interface that are neither active nor default such as ProductRelationshipValidationImpl (4).
An interface can have different types of implementations, such as:
-
Default Implementations: Each interface has a default implementation which means there’s no logic, only a stub that allows the CPQ Cart to function without any rules. Stub or non-operative interfaces and implementations receive input and return the same input as output without modification.
Salesforce provides a variety of interface implementations that support rules. You must activate different implementations to apply rules. The default implementations allow the Cart to run, but they don’t invoke any rules.
-
Salesforce Industries Implementations: Salesforce supplies a variety of out-of-the-box (OOTB) implementations for each interface. You can choose the implementation that best fits your business needs.
-
Custom Implementations: You can create your own custom implementations using Apex code.
-
Hybrid Implementations: You can also create a hybrid solution that combines Salesforce Industries and custom implementations.
Remember, you can build your own implementations and choose what data to incorporate to solve any problem. Implementations determine which data or metadata to use, how to use it, and the sequence in which to use it. In the next unit, you explore the importance of interfaces and implementations in defining Industries CPQ rules. Meet you there!
Resources