Replies: 4 comments 2 replies
-
Do I understand it correct that with the proposed changes we now have to extend the fflib_SObjectDomain class twice on 2 different concrete classes - first calling it Domain and second calling it Triggerhandler ? |
Beta Was this translation helpful? Give feedback.
-
woo-boy - thanks for engaging the community here. I see that a 4th edition of Andy Fawcett's book will need to accompany this PR as that book is by far (IMO) the best way to learn fflib. Plus Trailhead modules will need updating. I agree that introducing fflib domain to people steeped in trigger handlers was a burden; especially if they had not read Fawcett's book. Of course, the temptation for "classically-trained apex devs" will be to put their business logic in the triggerhandler class and skip using the domain class altogether. I see heated arguments during the PR step in the dev cycle. Some questions: a) The inner class
Is this the sort of functionality envisioned for d) My existing domain classes tend to have either static constants or accessors for frequently referenced values across testmethods and logic; e.g. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the summary of changes. I'm new to the library and it appears current books/documentation/videos have not caught up with this change. Since the last comment on this thread was more than 1 year ago, does anyone know of any blog posts, documentation, or videos that discusses how best to use these new objects? I realize the sample application has been updated, but it would be nice to see some more examples/patterns on how to properly apply these objects in real world scenarios, including how to mock these in tests. Thank you. |
Beta Was this translation helpful? Give feedback.
-
I think, but @wimvelzeboer would know best, but the example sample application is the best I've seen. The books used subclasses of fflib_SObjectDomain to be both the triggerhandler and the domain. E.g. The new structure breaks out the triggerhandler methods into a class named Domains are supposed to be named One thing the change did is no longer restrict domains to SObjects; they can be any business "domain" you want as they operate on a list of Domains can continue to be mocked with ApexMocks (via the |
Beta Was this translation helpful? Give feedback.
-
TL;DR -
fflib_SObjectDomain
is both a Trigger Handler and a Domain. The blurring of these two concerns into one class creates a challenge when training new engineers to the Apex Enterprise Patterns (AEP). We propose to separate the Domain from the Trigger Handling features of fflib_SObjectDomainThrough the hard work and advocacy of William Velzeboer @wimvelzeboer , we are planning to make a structural change to the longstanding SObjectDomain class in fflib-apex-common. William’s pull request separates the Domain out of SObjectDomain and into its own class and interface -- free from any trigger handling concerns.
All of the maintainers of the AEP repositories have tested this PR against our own internal production/proprietary projects and found no functional regressions. We are now giving notice that we will merge this change on April 1, 2021 unless reasonable objections to the approach or substantive functional-regression issues are raised.
To repeat: Existing code that extends
fflib_SObjectDomain
should continue to function, unmodified, even after merging in the new version of the AEPs.In summary:
fflib_IDomain
- a new interface that represents a collection of Object instancesfflib_IObjects
- an interface extendingfflib_IDomain
for collection manipulation of the Domainfflib_ISObjects
- an interface extendingfflib_IObjects
that provides access to the SObject instancesfflib_Objects
- a concrete implementation offflib_IDomain
that solely deals with Objects (not SObjects) and provides expected methods for manipulating collections of objects.fflib_SObjects
- an extension offflib_Objects
that adds additional methods for manipulating SObject collections -- such as filtering to return a subset of records, retrieving all the values of a field or updating a field in bulk.fflib_SObjectDomain
- has been modified to remove the state management for the Domain and delegate it to afflib_SObjects
instanceThe pull request is here:
#300
William has also provided a working example in the sample code repo for review:
apex-enterprise-patterns/fflib-apex-common-samplecode#27
Please provide feedback either on the PR itself or, if it's a more general concern, on this discussion thread. The deadline for feedback is March 31, 2021
Beta Was this translation helpful? Give feedback.
All reactions