7
votes
Accepted
fflib selector - configure Read and FLS - fflib_SObjectSelector vs fflib_QueryFactory
You should always call a selector class and the methods within that
class ... eg selectXxxByYyy(...) then exploit the queryfactory class
to construct queries , especially composite queries. The ...
7
votes
Accepted
fflib apex common Usage
If you plan on using fflib, then best practice is to adopt its conventions as documented in GitHub, Trailhead, and Andrew Fawcett's book Force.com Enterprise Architecture Second Edition (which is well ...
7
votes
fflib as Second Generation Managed Package (2GP)
I'll start this answer by recognizing that questions which solicit opinions, rather than objective answers, are frowned upon on StackExchange.
Having said that, the question was framed beautifully and ...
6
votes
Accepted
Apex Enterprise Patterns: Should UOW only be used with a DML transaction?
Patterns are tools, and like tools, there's no point in using a tool if you don't understand its purpose; it can easily cause more harm than good. Similarly, there's no point in using a tool if it's ...
6
votes
Accepted
Any option for mocking custom metadata records using fflib-ApexMocks and fflib-apex-common?
For me, it totally makes sense to get a record of AppointmentSettings__mdt from the selector's method so that it can be canonically mocked using fflib-ApexMocks in unit tests:
Create an ...
5
votes
Mocking Database.QueryLocator in Unit Tests using fflib Apex Mocks
Currently, I came up with some ugly but efficient solution for mocking Database.QueryLocator and to be precise, its substitution.
To change the return type of AccountSelector.locatorByIds() method ...
5
votes
fflib as Second Generation Managed Package (2GP)
G'day folks. Apologies for being a bit late to this discussion.
@lightxx -- There are pros and cons about separating the fflib classes out to a new package.
All things being equal, it makes sense to ...
4
votes
Accepted
mocking related objects using fflib
I learnt that the way to mock a related list of an object in fflib is by using the method fflib_ApexMocksUtils.makeRelationship.
Solution:
fflib_ApexMocks mocks = new fflib_ApexMocks();
Opportunity ...
4
votes
Accepted
benefits of using interfaces in fflib service layer
It was implemented with interfaces to allow dependency injection (for example, for mocking). This way you can create other classes that implement the interfaces and use them (inject them) in runtime. ...
3
votes
register relationship
Objects passed to the constructor of fflib_SObjectUnitOfWork must be in dependency order for the commitWork() method to insert them in the correct order. In your case Account.SObjectType must be ...
3
votes
Accepted
Do we have to force all FFLIB classes with `with sharing` keywords to pass security review?
You could mark them inherited sharing, which means "with" unless called from a "without" context.
3
votes
Accepted
How to mock App Exchange package's API response?
I cannot mock app-exchange package method, but I can mock my method, which calls the package. This will stop the code entering package and get me to do what I want.
public class APIProcessingService
{...
3
votes
fflib selector - configure Read and FLS - fflib_SObjectSelector vs fflib_QueryFactory
The fflib selector design pattern and its query factory has been an old-fashion and cumbersome design. Say if you wrote a function selectById with only a list of Id as the parameter, and has been put ...
Community wiki
3
votes
Accepted
Which unit tests should check read access for user?
The selector itself must be tested. Without it, you cannot verify that it will work for all intended use cases. Further, without a test on the selector, each controller using it would need to ...
3
votes
fflib_ApexMock: How to mock static methods?
I was looking for the same solution, but it doesn't appear that FF plan to implement it as of now. Here is where it was reported as an issue on the repo and they replied saying they couldn't ...
3
votes
What value is there in an Application Service Provider
The main benefit to this pattern is Dependency Injection, which has many benefits which you could spend entire weeks reading up on. I won't speak to your other questions, but this aspect I am familiar ...
3
votes
Accepted
Why does the FFLIB framework enforce CRUD security and sharing rules by default for Domains?
I believe the answer is the fflib was originally designed for the ISV world where such checks are desired. By having all your domain classes inherit from an intermediary class, say ApplicationDomain ...
3
votes
FFLib Selectors with SOQL For Loops
We can't use custom Iterator in a for each loop, which would be necessary in order for us to leverage the QueryLocator for loop pattern. So, given we can't do this, we would need to change the ...
3
votes
Accepted
How to disable CRUD/FLS check from fflib domain layer for only some specific flows. By default it is enabled for all flows using base class
I have find one workaround for my requirement.
My flow is
Create a static variable isSupportCRUD with default value true in Base domain class.
Create a new method disableTriggerCRUDSecurity() in the ...
3
votes
Accepted
How to add ALL ROWS in fflib selector class
Seems like there is no fflib solution for it. Append the ALL ROWS string at the end of a built query string.
public List<AccountTeamMember> selectByDeletedId( Set<Id> ids)
{
...
3
votes
Lean, fast and flexible replacement for the fflib QueryFactory
It might be useful for you to include what features you're looking for in a query builder in your question. Because it's not obvious to me what you would need, like, dislike in a query builder. e.g. ...
3
votes
what is the role and meaning of "=>" operator (it's called maps to) in apex enterprise pattern application class ? Please explain
It's... just another operator that Apex provides?
There's no special meaning here, no hidden message to decipher. It's used when you're initializing a Map.
Break down the statement into parts, and ...
3
votes
Accepted
Mocking Relationship Over Multiple Levels With Apex Mocks
Your problem lies here:
new Map<SObjectField, Object>{
User.ContactId => fflib_IDGenerator.generate(Contact.SObjectType),
user.Contact.Name => 'Joe',
user.Contact.Patient__c....
3
votes
Accepted
fflib: selector Method query giving me error of Duplicate field selected
You have:
public List<Opportunity> selectByDynamicFilter(List<String> lstOfSobjectFields,String strFilter, String strRecordId){
fflib_QueryFactory query = newQueryFactory()....
2
votes
Salesforce Selector layer - subquery
Your method
public List<Opportunity> selectByIdWithLineItems(Set<Id> recordIds){
fflib_QueryFactory query = newQueryFactory();
query.setCondition('Id IN :recordIds');
...
2
votes
Stuck on Unit of Work Principles test in Trailhead
While it works, you don't need to resgister the relationship twice. Once registered, you may simply RegisterNew the note ( workUnit.registerNew(myNote) )
2
votes
Accepted
Stuck on Unit of Work Principles test in Trailhead
Make the changes in code as below . And you would be able to pass the trailhead.
workUnit.registerRelationship(myNote,Note.ParentId, cont);
workUnit.registerNew(myNote, Note.ParentId, cont);
Make ...
2
votes
how to prevent recursive trigger when using the financialforce enterprise design patterns library?
The answer is no longer true about fflib
In 2016, Disabling trigger events in Domain layer was added
fflib_SObjectDomain.getTriggerEvent(YourDomain.class).disableAll(); // dont fire anything
...
2
votes
Which unit tests should check read access for user?
In addition to @sfdcfox answer let me add an added bonus for having a selector test class:
Once the selector is thoroughly tested, you can them mock the selector in tests of services, domains, and ...
2
votes
Accepted
Pros and cons of fflib-common-apex for ISV
The library is licensed by the BSD 3-Clause "New" or "Revised" License. While this hasn't been tried in court, having such a license would make it very difficult for FinancialForce ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fflib × 82apex × 57
unit-test × 20
apexmock × 20
trigger × 6
design-patterns × 5
soql × 3
domain-layer × 3
query × 2
dml × 2
files × 2
isv × 2
architecture × 2
crud × 2
enterprise × 2
mock × 2
stubapi × 2
community × 1
batch × 1
controller × 1
code-coverage × 1
error × 1
security × 1
sobject × 1
apexrest × 1