Skip to main content

Posts

Performance benefits of declaring Apex variables as Final and dynamic dispatch .

D ynamic dispatch is the process of selecting which implementation of a polymorphic method to call at run time. It is commonly employed in, and considered a prime characteristic of, object-oriented programming (OOP) languages and systems.  Polymorphism in object-oriented programming is the phenomenon where objects of the class expose an operation of the same name but possibly differing in behavior. Dynamic dispatch contrasts with static dispatch, in which the implementation of a polymorphic operation is selected at compile time. The whole purpose of dynamic dispatch is to defer the selection of an appropriate implementation until the run time type of a parameter is known. A polymorphic operation has several implementations, all associated with the same name. With dynamic dispatch, one particular implementation of an operation is chosen at run time.  In apex programming methods and classes are final by default. You cannot use the final keyword in the declaration of a ...

Invocable Methods in Flows – Focused mechanism with single action.

D evelopers can use the Invocable Action mechanism to build a functionality which could be used by admins or non-coding consultants to do declarative programming around process builders and flows salesforce technology . To build focused action we need to use apex class that accepts inputs and returns data via output parameters. Admins can use input fields via flows to supply input into the apex method and use output parameters to return data back to UI via flows (screen flows). Use the @InvocableMethod annotation to identify methods that can be run as invocable actions and use the @InvocableVariable annotation to identify variables used by invocable methods in custom classes. Packaging Invocable Actions (managed packages): You can build packages with invocable methods, once included the invocable method cannot be removed from later versions of the package. Public invocable methods can be referred to by flows and processes within the managed package. Global invocable methods can be refe...