Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs

Questions tagged [design-patterns]

A general reusable solution to a commonly occurring problem within a given context in software design

Filter by
Sorted by
Tagged with
0 votes
1 answer
55 views

What order should one adopt a service/selector/domain/unit of work pattern in a legacy codebase?

Just inherited a 4 year old Salesforce Apex codebase. I am a first timer to Salesforce at this point but have a lot of dev and architecture experience in other codebases and languages. Team is small. ...
Shaun's user avatar
  • 151
1 vote
1 answer
134 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 ...
mmm321321's user avatar
  • 659
0 votes
1 answer
31 views

Where to find best practice architectural design for managed packages

I am relatively new to managed packages, we have a 1st gen package that I am actively maintaining and I have noticed in one specific area there is a lot of global properties and methods. Which means ...
Bill Woodson's user avatar
1 vote
2 answers
161 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)] ...
Swisher Sweet's user avatar
0 votes
0 answers
82 views

Object Oriented APEX Anyone?

I am trying to make my APEX object-oriented. Here's the ERD, And here's the requirement A user can charge an opportunity based on the hours they spent and their grades. Grades are stored as a custom ...
Hareesh Mohan's user avatar
0 votes
1 answer
59 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: ...
Damecek's user avatar
  • 1,948
1 vote
3 answers
304 views

Apex: when to use private set in a singleton?

I'm trying to understand when to use private set in singleton vs not using private set. For example: public static Boolean runningInASandbox { get { if (runningInASandbox == null) { ...
snippet69's user avatar
1 vote
0 answers
301 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 ...
Doodool_Tala's user avatar
0 votes
1 answer
123 views

How to incorporate cross-object logic on domain class using Apex Enterprise Patterns

Using the Apex Enterprise Patterns, I would like to incorporate cross-SObject logic in my domain class. Is the following example a correct implementation? Interaction__c records are created with ...
Doodool_Tala's user avatar
3 votes
1 answer
622 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 ...
Swisher Sweet's user avatar
0 votes
2 answers
510 views

How Singleton pattern with Early Initialization vs Lazy Loading in Apex differs?

I was going through the articles on the Singleton pattern in apex and came up with an example that describes Early Initialization vs Lazy Loading in the Singleton pattern. Early Initialization: public ...
user2943892's user avatar
0 votes
1 answer
75 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 ...
Carryonplease's user avatar
-1 votes
3 answers
149 views

How to update accounts & contacts from public forms without destroying existing data

We have Form Assembly forms publicly available on the internet which are working well. Within these forms, we collect a lot of data about our clients (350+fields). We want to bring that data into ...
Jay's user avatar
  • 676
1 vote
0 answers
412 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 ...
Swisher Sweet's user avatar
15 votes
2 answers
1k views

Modularize (existing) LWC for reuse and flexible distribution

I am currently breaking a monolithic 1GP Managed package into more modular 2GP packages. While doing this I also want to decompose chunky LWC components in a way so they can be reused more flexibly ...
Robert Sösemann's user avatar
0 votes
1 answer
1k 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 ...
Jwok's user avatar
  • 769
4 votes
2 answers
1k views

How to remove records to be processed from before update trigger

I am working through my first implementation of a trigger + handler framework. I'm trying to figure out what I think is a pretty basic scenario: how to remove items from my trigger so that only those ...
aljmet's user avatar
  • 43
0 votes
1 answer
69 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 ...
Alex Chardouvelis's user avatar
1 vote
0 answers
98 views

Approach to Map Inbound Web Service Request Fields to a Defined Wrapper Class?

We have multiple external systems POSTing callouts to a salesforce custom web service. We need an approach to map the request fields from these external systems to a generic defined wrapper class. We ...
Akshay Poddar's user avatar
1 vote
2 answers
185 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 ...
oldgunner's user avatar
0 votes
1 answer
128 views

Apex Enterprise Pattern for universal usability

Everyone! I have a question - what if i don't want what kind of objects i will get? One day it is Accounts, next day - Opportunities, etc. Can I write Application.cls something like this? { // ...
oldgunner's user avatar
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 ...
Morgan Marchese's user avatar
5 votes
2 answers
509 views

Generic Platform Event - Centralize routing or not?

My App has a single multipurpose Platform Event called MyEvent__e which is emitted by MANY publishers and for MANY Topics. Receivers and subscribers need to subscribe to the event type and then do ...
Robert Sösemann's user avatar
0 votes
1 answer
426 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 ...
stuart Johnson's user avatar
0 votes
0 answers
40 views

Techniques for managing integration that uses data from two objects which can be updated independently or together

We have an integration that pushes name, title, manager, and a few other fields from our HR system (a managed package on force.com) to a custom c# endpoint that updates active directory. Name and ...
gorav's user avatar
  • 4,537
2 votes
0 answers
201 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 ...
Sonali takke's user avatar
4 votes
2 answers
260 views

If I Use a Loan Pattern is Salesforce smart enough to do a SOQL for loop?

As we know, Salesforce does some magic when you do something like: for (List<Account> accountList: [SELECT Id, Name FROM Account WHERE Name LIKE 'Acme%']) { // do stuff } ... such that the ...
Brian Kessler's user avatar
7 votes
2 answers
2k 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 ...
Robert Sösemann's user avatar
2 votes
1 answer
663 views

Soft-Delete in Salesforce for All data[For Auditing]

We have a requirement to maintain every data(even deleted also) for approx 10-15 yrs with its Audit history. We have Salesforce-shield is enabled so maintaining Audit data is taken care of by it. ...
Ysr Shk's user avatar
  • 3,157
0 votes
1 answer
746 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 ...
sfdcnewbie's user avatar
0 votes
1 answer
1k views

Regular expression is not working as expected in apex

I'm working on design patterns while I'm testing in the anonymous window it's working as expected. But when i trying to implement the same logic it's unable to find matches My expression:'^([0-9])\\1*$...
Pavan tej's user avatar
  • 1,460
0 votes
1 answer
278 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, ...
Andrew L.'s user avatar
  • 837
4 votes
0 answers
245 views

A folder structure that follow enterprise design patterns

I come from ASP.net background and I used to have a standardized folder structure such as this. I just jumped on a huge project with a lot of custom code. I'm sick of having to scroll through ...
Nino Y's user avatar
  • 291
1 vote
0 answers
141 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 ...
user2945545's user avatar
3 votes
0 answers
960 views

Dynamic class invocation in trigger - Callable Interface

Recently I was tasked with a project to dynamically call a class from a packaged trigger. This will also clients to hook into their custom logic instead of what is supplied as part of the package. I ...
Mitesh Sura's user avatar
6 votes
1 answer
738 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 ...
Shamina's user avatar
  • 4,275
2 votes
1 answer
288 views

Can't create relationship with Account and Custom object when using FF Unit Of work

I working on a class that needs to insert several records and create relationships between them, mostly to the Account object. I'm passing a deserialized JSON (WrapperRestZopaProviderRequest) to the ...
Carlos Naranjo's user avatar
0 votes
1 answer
134 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. ...
brownginger's user avatar
9 votes
1 answer
887 views

How to opt out of FLS validation when a SOQL query is run by a trigger?

I have a large Salesforce application with hundreds of SOQL queries. Currently, the code uses Schema.DescribeFieldResult data to determine if the logged in user has rights to each field in the SELECT ...
SeanW's user avatar
  • 672
3 votes
1 answer
317 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 ...
vignesh's user avatar
  • 2,704
3 votes
1 answer
63 views

Using Salesforce as Single Source of Truth [closed]

From a software architecture perspective, are there major issues with using Salesforce as an application's single source of truth (as opposed to a traditional relational database like Postgres)? It ...
Stud Sterkel's user avatar
1 vote
2 answers
74 views

Best Practice: dependency on data model names [closed]

BACKGROUND I need to display some data from another system on a lightning component. Let's say I get a JSON string from the external system as following: { "initialStatus": "Active", "name": "...
Eduard's user avatar
  • 5,139
-1 votes
1 answer
103 views

Apex-optimized algorithm for "road atlas city distance matrix" style utility data? [closed]

I'd like to automate a business process that currently involves a road-atlas-style "distance chart" as seen here. When an employee is hand-reviewing records for deduplication, if a given "status" ...
k..'s user avatar
  • 1,217
5 votes
3 answers
2k views

Platform Event Design when Subscribers are Apex Triggers

This is a general design question on how to structure trigger files for platform events. Say I publish a platform event "lead created" and I want to do several distinct things within the same ...
willard's user avatar
  • 997
24 votes
2 answers
4k views

Apex Framework / library for consuming REST services

To consume REST services there is a lot of boilerplate code needed: Build Apex Objects to model the responses Code to deserialize REST responses to those classes Handling of HTTP requests, responses ...
Robert Sösemann's user avatar
1 vote
1 answer
139 views

Design Pattern for Updating Records?

A while back I wrote an Apex class to handle opportunity splits. I couldn’t use the Opportunity Splits object because there were splits on three different corporate levels (with one-to-many or many-...
djackiem's user avatar
  • 179
0 votes
1 answer
1k views

call Messaging Queue every 5 Minutes [closed]

I want to make Integration between Salesforce and ActiveMQ(Is is a messaging server where the company send and save messages in this service). The Context: Every 5 Minutes should salesforce a ...
AZIZ's user avatar
  • 11
1 vote
2 answers
507 views

How to use trigger design pattern: ERROR Constructor not defined: [CaseTriggerHandler].<Constructor>()

I am trying to follow the best practice design patterns for triggers but get the error Constructor not defined: [CaseTriggerHandler].(). What am I missing? Trigger trigger CaseTrigger on Case (...
Thomas's user avatar
  • 2,298
1 vote
1 answer
4k views

fflib apex common Usage [closed]

We have a existing salesforce implementation, we have most of the logic in triggers and trigger handlers. We are still using classic and no mobile or other UI. But still we are planning to implement ...
ab0369's user avatar
  • 365
3 votes
1 answer
991 views

Trigger design pattern - Where to add decision making logic?

Looking for some suggestions/lessons learned, etc., regarding where to add the decision-making code that determines if some code should run after a particular field update in a trigger context. For ...
Pablo Gonzalez's user avatar