Skip to content

Instantly share code, notes, and snippets.

@rsoesemann
Last active April 26, 2019 07:50
Show Gist options
  • Save rsoesemann/43529fb435a6e0c69bcddb61d8231e6b to your computer and use it in GitHub Desktop.
Save rsoesemann/43529fb435a6e0c69bcddb61d8231e6b to your computer and use it in GitHub Desktop.
(fflib) Domain classes should have no logic besides User Story-related commands
public with sharing class Opportunities extends fflib_SObjectDomain {
public Opportunities(List<Opportunity> records) {
super(records);
}
public override void onAfterInsert() {
new ApplyDefaultCurrency(recors).execute();
new CalculateRevenueForecast(records)
.andThen(new PublishLeadScore().forNew(records)).execute();
}
public override void onAfterUpdate(Map<Id,SObject> old) {
new EnhanceContactData(records).execute();
new CalculateRevenueForecast(records)
.andThen(new PublishLeadScore().forChanged(records)).execute();
}
public override void onValidate() {
new VerifyThatUser().hasAdvancedPermission(records);
new VerifyThat(records)
.complyWith(new AccountInformationRules())
.haveNoPotentialDuplicates();
}
public override void onAfterDelete() {
new RemovedDependantRecords(records).execute();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment