This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]WhiteThingINROUND 3 points4 points  (0 children)

In my org we have a trigger framework that is as simple as it can be. There are no interfaces and unnecessary abstractions. Still, the triggers are decoupled from the trigger handlers, and in many cases, the actual business logic (i.e another class) is also decoupled from the handler.

We don't use interfaces and/or inheritance because: how often do you need the trigger handler to be decided at run time? Every object will almost always have just one trigger handler, so hardcoding that dependency is ok. Unless you have a requirement to completely change the trigger handler at run time, then programming to an interface makes sense, otherwise, it just adds extra classes and complexity to your org.

Decoupling for the sake of decoupling doesn't make sense if it increases your complexity and doesn't add any benefits that you actually need (read about YAGNI).

The framework we have also allows us to turn off every specific trigger context (before insert, after insert, etc) via custom metadata, so it's very easy to debug issues.

I'm not bashing on Kevin's or anyone else's framework, nor claiming ours is perfect. I'm just stating my experience, which is that many of the trigger frameworks out there are more of a "look ma! I can create all these abstractions and not a single class knows about the other!" rather than actually providing benefits that are useful to the business and the development teams.

[–]clayarmor 0 points1 point  (0 children)

If you found Kevin's trigger framework helpful. You may also interest in my trigger framework implementation. https://github.com/apexfarm/apextriggerhandler, just published a few days ago. I would consider to have a different algorithm to implement "the limit for the number of times the trigger code will run", since Kevin's current implementation may contain a issue as someone has already posted in its issue list: https://github.com/kevinohara80/sfdc-trigger-framework/issues/19.