💃 Hot tip for Salesforce Devs🕺

Extend your functionality natively! 🔥

Good morning, Salesforce Nerds!

Did you know Salesforce has provided an elegant way for devs to extend ➡️ functionality between applications?

Imagine being able to add customized logic to an AppExchange app with a little bit 🤏 of Apex.

Or maybe you just want to add logic to an existing codebase in a loosely-coupled way. 🤷 

Either way, there’s an Interface for that! 🤘 

Read on, nerd out with me. 🤓 

RIP

Agenda for today includes

  • A secret weapon for Salesforce Devs

  • Daily Principle

  • All the Memes

A secret weapon for Salesforce Devs

📆 Today we’ll cover:

💃 What is it? 🕺

💃 What is it for? 🕺

💃 Code 🕺

salesforce

Job Board | 💃 Click Here 🕺 

Socials | 💃 Linkedin | Instagram | Twitter!🕺

🤔 What is it?

The Callable Interface! 🥳 

At the end of the day 🗓️ it’s just another interface that devs can leverage.

Not sure what an interface is or why they’re important? 🤔 

One of the definitions is:

“The place at which independent systems meet and act on or communicate with each other”.

In terms of software development, think of them as how the different components of your application🔊 communicate with each other.

We don’t want our classes to be directly tied 🪢 to each other. This results in a brittle codebase that can be hard to work with.  

Interfaces allow us to indirectly tie 🌉 them together. The result is a much more robust system.  

So, what’s so great about the Callable Interface?

Well, the official definition says it …

Enables developers to use a common interface to build loosely coupled integrations between Apex classes or triggers, even for code in separate packages. Agreeing upon a common interface enables developers from different companies or different departments to build upon one another’s solutions. Implement this interface to enable the broader community, which might have different solutions than the ones you had in mind, to extend your code’s functionality.

Yeah, I know … 😴💤😴 

But, they’re right. 🤘 

The powerful thing about the Callable Interface is that is exists in the System namespace.

To a dev, that means it’s vanilla-Apex. Built into the platform and any other dev or any app can use it.

👉️ What is it for?

While Interfaces themselves are useful for many reasons let’s look at Callable.

If you ask me, this interface is ideal for extending ↔️ existing functionality across applications.

Let’s use an example:

You’re firm has a Managed Package (or maybe Unmanaged that serves as a foundation)

You have an interested client

They insist they must be able to extend the business logic in your app with their own

This can be tricky.

We can’t modify (or even see) the code in a managed package and it can be scary as hell 😱 to modify an unmanaged package.

No sweat, luckily your dev team reads 💃 ChaCha 🕺 on the regular.

They already know:

System Namespace + Common Interface = Extensible & Loosely Coupled Code

🧑‍💻 Example:

Let’s see a simple example in code. 👀 

This is straight out of the dev guide, btw …

We have a class named Extension that implements the Callable interface.

This requires us to implement the call function.

This function takes a String argument named action, this just holds the name of actual method we’re going to invoke.

The second argument is named args and is a Map<String, Object>. It’s key-value pair of the arguments that will get passed to the actual method.

So now, the calling code would look something like this:

Here we new up a concretion of the Callable interface, invoke the call method and pass in the required parameters.

These parameters route the code to the correct method and pass it the data it needs to complete execution. 💥 

Daily Principle

"Humanity must seek what is NOT simple and obvious using the simple and obvious."

Musonius Rufus

and now....Your Daily Memes

I really tried guys …

Execution path

Been there man, it’s rough

What did you think about today's newsletter?

Login or Subscribe to participate in polls.