All developers glue Apex code together from different sources. But it’s also a developer’s job to worry about dependencies. When we needed a way to implement loosely coupled integrations, Andrew Fawcett floated a possible solution:

The delivery of Callable in API 44.0 finally allows developers to address the “ripple effect” where modifying one class causes many downstream changes.

Streams uses the Callable interface so that developers and consultants from different companies can create services that communicate across namespaces.

public class Service implements Callable
{
    public Object call(String m, Map<String,Object> event)
    {
        return new List<Object>
        {
            // intended side effects go here
        };
    }
}

Although Type.forName always supported casting to interfaces, somebody always had to be the master of a custom interface. Now it’s part of the platform.

Related Posts

Last modified: 25th June 2020

Comments

Write a Reply or Comment

Your email address will not be published.