Questions tagged [design-patterns]
A general reusable solution to a commonly occurring problem within a given context in software design
145 questions
0
votes
1
answer
20
views
Where do we instantiate Unit of Work? Domain or Service layer?
I’m implementing the fflib-style Apex Enterprise Patterns in my org and I’m confused about the correct place to instantiate the Unit of Work (UoW).
From what I understand:
The purpose of UoW is to ...
0
votes
2
answers
77
views
Confused about responsibilities of Domain Layer vs Trigger Handler in Apex Design Patterns
I’m learning Apex design patterns and following Trailhead modules. So far, I’ve created base-level selector classes for the Opportunity object and now want to implement the next layer.
From what I ...
1
vote
1
answer
97
views
fflib - How to handle before context trigger updates in domain class methods
To note: I've just implemented fflib and have thus separated TriggerHandler logic from SObject Domain classes. That is, I have (for example) two classes:
AccountsTriggerHandler extends ...
0
votes
2
answers
528
views
Accessing relationship fields in fflib
We are trying to develop our code using fflib. Can we access relationship fields directly in the child domain class or do we need to use the parent object domain to access the field values and sent it ...
2
votes
4
answers
2k
views
Design patterns - benefits of using with Apex code
I have been asked in Interview that why did I use Design patterns just for one or two methods, when can you use helper classes to get the things done for you.
I explained that having Quote with more ...
1
vote
1
answer
305
views
Enterprise Architecture, Domain layer - handling multiple records
I'm developing a project using fflib's Enterprise Architecture patterns, based on their example app (https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode). I am a bit confused ...
1
vote
2
answers
260
views
How to perform a SOQL in clause using Apex Enterprise Patterns Selector?
I'm setting an an AEP Selector which needs to implement the following:
[select ParentId from SetupEntityAccess where SetupEntityId in
(select Id from CustomPermission where DeveloperName = :name)]
...
0
votes
1
answer
78
views
lightning-datatable column builder class
Why did Salesforce choose this approach with the column definition of the lightning-datatable component?
const columns = [
{ label: 'Label', fieldName: 'name' },
{ label: 'Website', fieldName: ...
1
vote
0
answers
487
views
With latest fflib, do TriggerHandlers become service class consumers? If so what happens to UoW?
With the latest fflib, the trigger handler and domain logic were separated. I can see from the changes to the repo that previously, the Opportunities.cls domain class' onAfterInsert() method updates ...
4
votes
1
answer
1k
views
What's the difference between fflib_SObjectDomain and fflib_SObjects?
We are implementing Apex Enterprise Design patterns in our org and I'm struggling to understand the difference between fflib_SObjectDomain and fflib_SObjects. There's very little documentation on the ...
0
votes
1
answer
115
views
Should I be using a better OOP pattern (DI, Factory?) for this API callout with a big wrapper class
I'm trying to up my OOP game and utilize good patterns where I can. Recently I wrote some classes that essentially take a custom object (a quote) and build a very long/complex api request body using a ...
1
vote
0
answers
531
views
Is there a design pattern for structuring Record Triggered Flows?
Whilst reviewing The Ultimate Guide to Flow Best Practices and Standards from Salesforce, I saw no mention of any design patterns or best practices on how to handle structuring Record Triggered Flows ...
0
votes
1
answer
2k
views
Why have service classes? (Service Layer Model)
tl;dr - What are the advantages of having handler and service methods separate housed in separate classes, rather than joined in a single class.
Background
Salesforce and others reference using ...
0
votes
1
answer
80
views
Handling Exceptions From Different Parts of the Code
I've got a case where different parts of the code need to handle exceptions differently, and was wondering if there is a pattern or a recommendation for approaching the problem. Let me explain exactly ...
1
vote
2
answers
197
views
How put inner class into Apex enterprise Pattern Service layer?
I need use structure (or wrapper class) in Apex Enterprise Pattern.
public with sharing class Structure {
public String name { get; set;}
public Integer limit {get; set;}
private ...
6
votes
1
answer
1k
views
Heap Size Optimization with commonly reused lists & variables
I recently joined a new, very large, very old org that is in need of optimization. Previously they had a tendency to create brand new, separate utility classes for each new method being called from ...
0
votes
1
answer
467
views
Pattern to integrate million record if BULK option not available
This is in reference to Integration with a System having millions of records.
However, due to certain limitation we do not want BULK API needs to be implemented . Although there are other options like ...
2
votes
0
answers
233
views
Enterprise Pattern : AccountsSelector: @Override specified for non-overriding method: List<Schema.SObjectField> sptSObjectFieldList()
We have AccountsSelector class extending ApplicationSObjectSelector abstract class from at4dx library.
ApplicationSObjectSelector class has public virtual method getSObjectFieldList()
I have ...
7
votes
2
answers
3k
views
Using System.runAs in all tests - Best practice or Antipattern?
When doing functional tests I see many people also check the permissions by using System.runAs(userWithRightPermission) in most of their tests.
I see good reasons for doing this, because then you ...
0
votes
1
answer
902
views
How Is Apex Singleton Different From Static Trigger Handler?
I've seen people opting for singleton pattern (https://developer.salesforce.com/wiki/apex_design_patterns_singleton) while writing trigger handler classes and some simply defining methods in trigger ...
0
votes
1
answer
328
views
Design Pattern Help: Extended Interfaces with methods that shared the same functionality/code
I'm trying to figure out the best pattern for the code below (example: not actual code). IOpportunitiesA and IOpportunitiesB are extending the base interface and they have a similar method, ...
1
vote
0
answers
150
views
Salesforce API design patterns [closed]
we are moving away from point to point integrations to Mule(API Led integration ) and are in the process of revamping our endpoints and thus having all the endpoints pass through mule anypoint , this ...
6
votes
1
answer
871
views
Can single Trigger by object cause performance issues?
Context
There are a lot of questions and SF developer blogs related to best practices for trigger.
Since several years, I've been following the single trigger object pattern which has a lot of ...
0
votes
1
answer
145
views
How to prevent aucomponent table from growing in size so that it changes the size of the component?
Hidden Component 3 is a table (not lightning data table.)
It is fetched with some data-- but when the text gets too large (even with truncation), the entire component will grow with the table.
...
3
votes
1
answer
373
views
Dynamic Component creation in Lightning webcomponent
As for my analysis Not able to render dynamic Lightning Web Component Dynamic creation of the Lightning Web Components is not yet supported.
Can someone suggest a better approach to render the input ...