Skip to content

Commit c903ddc

Browse files
author
Wim Velzeboer
committed
Add documentation for new domain structure
Some issues were raised around the change to the new domain structure. This PR adds a Update message and a support page that lists the most important items, known issues and how to resolve them.
1 parent f922242 commit c903ddc

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ FFLib Apex Common
1414
Updates
1515
=======
1616

17+
- **April 2021**, **IMPORTANT CHANGE**, the fflib_SObjectDomain has been split into a domain (fflib_IDomain) and triggerhandler (fflib_ISObjectDomain). This change can impact existing projects, please review [this page](docs/202105-new-domain-structure.md) for more details.
1718
- **April 2020**, **IMPORTANT CHANGE**, the directory format of this project repo was converted to [Salesforce DX Source Format](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_source_file_format.htm). While the GIT commit history was maintained, it is not visible on GitHub. If you need to see the history, either clone the repo and execute `git log --follow` from the command line or refer to this [tag](https://github.com/apex-enterprise-patterns/fflib-apex-common/tree/metadata-format-prior-to-dx-source-format-conversion) of the codebase prior to conversion.
1819
- **September 2014**, **IMPORTANT CHANGE**, changes applied to support Dreamforce 2014 advanced presentation, library now provides Application factories for major layers and support for ApexMocks. More details to follow! As a result [ApexMocks](https://github.com/apex-enterprise-patterns/fflib-apex-mocks) must be deployed to the org before deploying this library. The sample application [here](https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode) has also been updated to demonstrate the new features!
1920
- **July 2014**, **IMPORTANT CHANGE**, prior **23rd July 2014**, both the ``fflib_SObjectDomain.onValidate()`` and ``fflib_SObjectDomain.onValidate(Map<Id, SObject> existingRecords)`` methods where called during an on **after update** trigger event. From this point on the ``onValidate()`` method will only be called during on **after insert**. If you still require the orignal behaviour add the line ``Configuration.enableOldOnUpdateValidateBehaviour();`` into your constructor.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# New domain structure
2+
The new domain structure allows more flexibility of the object type a domain can contain.
3+
This allows for the creation of compound-domains and domains of data-classes.
4+
5+
It also splits the functionality into a Domain Model [as described by Martin Fowler](https://www.martinfowler.com/eaaCatalog/domainModel.html) and a separate trigger handler.
6+
This helps to structure the code better and makes it more clear which Apex code should be in the domain and which in the trigger handler.
7+
8+
9+
10+
## Previous interface and implementation structure
11+
| Interfaces | Implementation | Description |
12+
|:---|:---|:---|
13+
| fflib_ISObjectDomain | fflib_SObjectDomain | Used as Domain and trigger handler
14+
15+
16+
## New interface and implementation structure
17+
| Interfaces | Implementation | Description |
18+
|:---|:---|:---|
19+
| fflib_IDomain | | Generic identifier for domains
20+
| fflib_IObjects | fflib_Objects | Domains constructed with Objects, e.g. data-classes
21+
| fflib_ISObjects | fflib_SObjects | Domain containing SObjectTypes, e.g. Accounts, Contacts
22+
| fflib_ISObjectDomain | fflib_SObjectDomain | Used for trigger handlers and for legacy domains
23+
24+
See [this PR](https://github.com/apex-enterprise-patterns/fflib-apex-common/pull/300) for a detailed overview
25+
of all the code changes which were part of this change.
26+
27+
The [fflib-apex-common-samplecode](https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode)
28+
also includes examples on how to structure the change into the
29+
[new domain](https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode/blob/master/sfdx-source/apex-common-samplecode/main/classes/domains/Accounts.cls)
30+
and [trigger handler](https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode/blob/master/sfdx-source/apex-common-samplecode/main/classes/triggerHandlers/OpportunitiesTriggerHandler.cls)
31+
32+
## Known issues and how to resolve them
33+
34+
35+
### _Issue:_ Ambiguous method signature: void setMock(MyDomainClass)
36+
This happens when you try to mock an old domain class which is extended from fflib_SObjectDomain.
37+
```apex
38+
Application.Domain.setMock(mockAssetsDomain); // <<== generates Ambiguous method signature: void setMock
39+
```
40+
The issue can be resolved by casting the mock implementation to fflib_ISObjectDomain:
41+
> Application.Domain.setMock( **(fflib_ISObjectDomain)** mockAssetsDomain);
42+
43+
[See this issue report for more information](https://github.com/apex-enterprise-patterns/fflib-apex-common/issues/347)
44+
45+
46+
### _Issue:_ Illegal assignment from fflib_Domain to fflib_ISObjectDomain
47+
The `newInstance` method signature of the Application Domain Factory (fflib_Application.DomainFactory) has changed into:
48+
>public **fflib_IDomain** newInstance(***);
49+
50+
If you have:
51+
```apex
52+
fflib_ISObjectDomain domain = Application.Domain.newInstance(sObjIds);
53+
```
54+
You need to change that into:
55+
> fflib_ISObjectDomain domain = **(fflib_ISObjectDomain)** Application.Domain.newInstance(sObjIds);
56+
57+
[See this issue report for more information](https://github.com/apex-enterprise-patterns/fflib-apex-common/issues/346)

0 commit comments

Comments
 (0)