Dependency Injection part 2

Patterns
Dependency Injection We have seen that we can utilize the Apex Type class to give us some kind of "dynamic processing", well, not quite yet. It's true that we can simplify things now but there are a couple of components in our structure that are still missing. So far we have one interface and two classes that are implementing our interface. Now we are going to add the dynamic part that makes dependency injection so powerful.  All we want is to supply our code with the correct class based on the user that is executing the apex transaction. We want this to be dynamic and we want one line of code to make that decision for us. Should I go 'right', should I go 'left'... we need to control de 'cross-road' and…
Read More

Dependency Injection

Patterns
Dependency Injection If you search for Dependency Injection you will find out that it has been around for quite some time. It is basically a technique on software development that allow us to remove any explicit dependencies as part of an apex transaction. In simple words we can say that this technique allows to "feed" our code with a particular class/es "dynamically".  I like to see it as some kind of "cross road" in which either way can be taken based on a particular logic. We can control the "dynamic" part with Custom Settings or Custom Metadata. This is an important piece of our puzzle because it is the one telling our code where it needs to go next.Which "road" to take from the "cross road"... Scenario We are going to take a…
Read More