-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds handleAndFinally context to fflib_SObjectDomain #491
Adds handleAndFinally context to fflib_SObjectDomain #491
Conversation
G'day @jamessimone Thanks for submitting this. Always appreciated! The team will review it soon and reach out if there are questions. Cheers! John |
@ImJohnMDaniel any update on this? |
@jamessimone -- re: the trailing whitespaces in the codebase is acknowledged by the team. Thanks for the callout. We will look into it a later time. |
@jamessimone -- Some of the review team have been on vacation. We will be reviewing this soon. We appreciate your patience. |
Thanks, appreciate it! |
Hi @jamessimone, Thank you for taking the time to contribute. The other maintainers and I have looked over your proposal and landed on the below follow-up. Are you aware of the DoWork feature on the SObject Unit of Work (SOUOW), which provides for the injection of logic to be completed upon a successful DML operation? The SOUOW, IDoWork interface specifies the structure of the injectable logic which is specified via the SOUOW.registerWork(...) method and consumed within the SOUOW.commitWork() logic. An example of its usage is illustrated in the If you are familiar with this feature, can you help us to better understand your use case(s) that necessitates the Also on a minor note .............. Thanks, |
@stohn777 This contribution came about as part of a suggestion made within Apex Rollup, and seems the most appropriate place to add the requested functionality. UOW cannot self-encapsulate all DML performed on platform, and seems an incomplete replacement for a consolidated approach within the actual triggers in question. As far as refactoring goes, I'd go so far as to say that taking code only runnable via a test out of production-level code is more significant than adding a no-op method to an existing class. While I can understand the reticence of the existing maintainers in undertaking a "big bang" approach to repository cleanup, the implication (that cleanup is of lesser concern) will continually push the actual undertaking of anything like a cleanup further down the road - to everyone's detriment, in my opinion. |
Hi @jamessimone, My apology not responding lately, due to an illness and work matters. Following-up a bit with your project's discussion and given the existing state of this project, I arrived at the most simple implementation of Apex-Rollup that I could think of [see below]. Am I missing anything? If not, then the addition of the The maintainers would prefer a more precise alignment with the native events provided by Salesforce's trigger feature. Additionally since this is a post-any-trigger-event logic, the door opens to a myriad of similar event-aggregations methods like, Please let me know if a significant gap is overlooked in the Commons triggerhandler framework that necessitates the inclusion of the public with sharing class DEV_OpportunitiesTriggerHandler
extends fflib_SObjectDomain
{
public DEV_OpportunitiesTriggerHandler(List<Opportunity> sObjectList)
{
// Domain classes are initialised with lists to enforce bulkification throughout
super(sObjectList);
}
public class Constructor implements fflib_SObjectDomain.IConstructable
{
public fflib_SObjectDomain construct(List<SObject> sObjectList)
{
return new DEV_OpportunitiesTriggerHandler(sObjectList);
}
}
public override void onAfterInsert()
{
// Rollup.runFromTrigger();
}
public override void onAfterUpdate(Map<Id,SObject> existingRecords)
{
// Rollup.runFromTrigger();
}
public override void onBeforeDelete()
{
// Rollup.runFromTrigger();
}
} |
@stohn777 it's certainly a convenience method - but what isn't? I respect your decision, though, and I'll close this as a result. I do hope that at some point in the future you all will consider some of my other suggestions, such as:
|
@jamessimone, those updates are eminently welcome. If you're willing to refactor your PR to remove the addition of the |
handleAndFinally
for consumers offflib_SObjectDomain
to opt into as something called at the end of each trigger run. This enables more idiomatic behavior, like a single place for committing logs (and, for my purposes, for rollups to be fired a la Rollup.runFromTrigger() in FFLIB Trigger Handler jamessimone/apex-rollup#605)fflib_SObjectDomain
by moving classes used only in tests into the corresponding test classfflib_SObjectDomain.Test
tofflib_SObjectDomain.TestFactory
to both properly represent the type it's referring to and eliminate the (probably unintentional) namespace shadowingAs a side note - fflib's files contain an enormous quantity of trailing whitespaces, which bloats file sizes unnecessarily. I'd recommend the entire repo be run through prettier at some point, or (failing that) at the very least the existing style of the code can be preserved while trimming the trailing whitespaces
This change is