#AntiPattern

Un vrai roman photo cette masterclass. Bientôt nous ouvrons aux premier/e/s invité/e/s. On n'en est qu'au premier tiers voir la moitié du montage (31 vidéos 236mn... long comme la séquence d'ouverture d'India Song de Marguerite Duras). Avec @claudeaubry #scrum #agilité #antipattern

Claude et Pablo discutent de l'antipattern : bureaucratieClaude et Pablo discutent de l'antipattern : absence de sens du travailClaude et Pablo discutent de l'antipattern : dissonance cognitive
sumanthvepasumanthvepa
2025-03-17

This is a common that I see with architecture. If you find yourself needing to implement a distributed two-phase commit over a multiple micro services, then you have most likely made the architecture too fine grained.

stackoverflow.com/questions/55

Indigo 🏳️‍⚧️:flag_nonbinary:psiie@anarres.family
2025-02-27

Real nice NYTimes

Not only did I not sign up for their newsletter (I did the free 3-day library thing) but they commented out their unsubscribe button in their email. LMFAO!

#NYTimes #antipattern #designfail #hostilearchitecture #helpImTrappedInAHashtagMakingFactory

Screenshot of HTML source code of an email from NYTimes. There is one line highlighted and it is commented-out. It reads: "To stop receiving our updates and offers," followed by code for a feature-rick html link with the destination.
2025-02-24

Can You Loop Inside a Loop?

A loop in programming is a control structure that repeatedly executes a block of code or low code as long as a specified condition is met. It enables programmers to automate repetitive tasks, iterate over data structures (like collections, arrays, or lists), and efficiently handle scenarios where the same operation needs to be performed multiple times. Using loops, developers can build cleaner, more concise code and reduce redundancy.

The simplest and most common way of looping in coding is through the use of a for loop. A for loop allows you to execute a block of code a specific number of times by defining an initialization, a condition, and an increment/decrement operation in a single, compact structure. It is widely used in many programming languages due to its clarity and versatility, especially when the number of iterations is known in advance.

Image source: https://admin.salesforce.com/blog/2022/automate-this-how-to-use-loops-in-flow

Loops within Loops (Nested Loops)

Loops within loops, often referred to as nested loops, are not inherently antipatterns, but they can become problematic depending on the context and scale of the data being processed. Nested loops are perfectly valid when dealing with scenarios that naturally require a hierarchy of iterations. However, they can lead to performance issues, especially when both loops iterate over large collections, resulting in increased complexity. This can significantly slow down the execution of code or low code.

Are Nested Loops an Antipattern?

When there are more efficient and optimized alternatives available, then nested loops become an antipattern. Additionally, deeply nested loops can reduce code readability and maintainability, making it harder for other developers (or even your future self) to understand and modify the code.

The key is to assess whether the nested loop is the simplest and most efficient approach for the given problem. If not, it’s worth exploring alternative strategies to improve performance and code quality.

Loops in Flow

Loop have limited functionality in flows: You have to loop over a collection, and you can only determine whether you want to loop first to last or the other way around. Salesforce flow lacks all the other sophisticated ways you can loop in code.

For loop can be achieved in Salesforce flow by leveraging the assignment and decision elements. A loop element cannot be used to create a for loop. To loop 5 times in Salesforce flow you do the following:

  1. Create a counter variable CounterVar.
  2. Increment the counter variable value by one using an assignment element functionality. Configure the assignment element to show CounterVar Add 1.
  3. Add a decision element to check whether the CounterVar equals 5. If not send to flow back to step 2.

Collections

In Salesforce Flow, collections are a type of variable that can store multiple values of the same data type, allowing you to manage and process lists or groups of records efficiently within a flow. Collections are particularly useful when you need to handle bulk data operations, such as looping through records, performing actions on multiple items, or passing data between flow elements, flows and code.

Salesforce flow also lacks the capability of building and processing complex collections compared to the the functionality in code.

When are Nested Loops Necessary?

When you are processing related records, nested loops may be necessary. Before you take that route, please consider more efficient alternatives by evaluation the following factors:

  • When modifying multiple records with the same field values, you don’t need to loop and build a collection to be used outside your loop. One single update element with criteria can do this for you. Example: Close all cases matching a specific criteria (e.g. under Account Acme).
  • When checking whether a specific junction object record exits before creating a new one, consider leveraging the collection filter element. This setup seemingly results in a nested loop because the collection filter outputs a collection. However, internal loop iterates at most a single time, and therefore does not present a performance concern.
  • When checking whether a record exists before creating it, consider leveraging the check matching record functionality in the create element. This functionality currently does not work for junction object records, and the matching record criteria builder is limited. Read Create by Checking a Matching Record in Flow to learn more about this functionality.
  • Check whether you can leverage the transform element to save one of the loops in your nested loop setup. Read 6 Things You Can Do With The Transform Element to learn more about this topic.
  • When comparing two collections and finding common and uncommon members, consider invocable Apex actions on UnofficialSF. These actions leverage the enhanced collection functionality in code to bring efficiency to your flow.

Optimize Collections and Avoid Nested Loop Pitfalls

In addition, consider using the assignment element for getting count of members in the collection, and the transform element for getting sum of number field values in a collection. While these are not tips related directly to nested loops, they may save you one loop within your nested loop configuration.

Finally, remember that the get element now supports a maximum number of records to get. This number can be set to any number between 1 and 2,000. Also note that the collection sort will take the same parameter while sorting the records, allowing the collection to be trimmed to a smaller member count.

If you considered all the alternatives, you can still use nested loops. Avoiding DMLs and SOQLs (Gets) inside your loops, you could avoid most of the governor execution limits. Your biggest risk is going to be hitting the dreaded Apex CPU limit error.

Conclusion

When designing Salesforce Flows, it is important to avoid nested loops whenever possible to maintain efficiency and prevent performance issues, especially when dealing with large datasets. Nested loops can significantly increase the number of iterations, leading to potential governor limit exceptions and reduced performance in the Salesforce environment. Instead, consider using collection processing techniques, such as using formulas, assignment elements, or collection filters. Additionally, leverage Apex Actions for complex logic. There are scenarios where nested loops are absolutely necessary, such as when processing multi-level data structures or implementing hierarchical logic. In such cases, it is crucial to minimize the loop size by applying filters beforehand and optimizing the logic within the loop. This ensures the flow remains scalable and maintainable. Ultimately, the key is to strike a balance between avoiding unnecessary complexity and using nested loops judiciously when the business logic demands it.

Explore related content:

Salesforce Flow Best Practices

Can You Use DML or SOQL Inside the Loop?

How The Transform Element Saves You Loops

#Antipattern #ForLoop #Loops #NestedLoops #SaleforceAdmins #Salesforce #SalesforceDevelopers

Flow loops imageTransform element in flow
Rey :ghosthug:nothe@notacult.social
2025-02-10

(and yes, I'm pretty sure I've filed a radar about it) #UX #antipattern

Rey :ghosthug:nothe@notacult.social
2025-02-10

I just need to whine a bit about a UX thing that ALWAYS gets me... please behold: the most unexpected clickable region! If you tap in this seemingly empty background area, it takes you to the “More Apple News Top Stories" page. #UX #antipattern

A screenshot of the mac Apple News app, with a red square over an empty background colored region and the text “THIS IS THE WORLDS MOST ANNOYING HYPERLINK, APPLE” in it. there is text to the right of the rect labelling the mentioned link, but it extends the entire width of the page, unexpectedly.
Thiago Bomfimthiagobfim
2025-02-06

Antipatterns are the opposite, this means that they are common wrong solutions for common problems, and knowing them are crucial to avoid these problems.

Read more 👉 lttr.ai/AaySL

2025-01-30

Just a friendly reminder that infinite scroll is an anti-pattern, and that building ethical social media is about more than ownership, algorithms, and licensing: Respecting users' time and not replicating patterns deliberately designed to create addiction is equally important. indieweb.org/infinite_scroll

#mastodon #pixelfed #loops #fediverse #UX #UI #FOSS #FLOSS #AntiPattern #AntiPatterns

Justin D Kruger (he/him)jdavidnet@me.dm
2025-01-24

Yeah, #PGE, I use more energy than the average person because I actually charge my #PHEV. (unlike the average owner ).

You shouldn't shame people for reducing their carbon footprint.

Ditch the #AntiPattern and support people #DeCarbonizing

#UtilityReform #PublicPowerSF #ScottWiener #GavinNewsom #DanielLurie
#EnergyPolicy #EnergyCosts #Electricity #SolarPunk #SolarPower #CarbonFootprint #UX #AntiPatterns
#CA #SF #SanFrancisco #SFBay #NorCal

George Girtonmartinicat
2025-01-23

Notice the user interface anti- pattern. The navigation for the Amazon app is directly below the button "don't my membership "very easy to make a mistake, and contravene your months- long intent to pause

just small circles 🕊smallcircles@social.coop
2025-01-18
Coach Pāṇini ®paninid@mastodon.world
2024-12-15

@jbigham

I hope one of the #LessonsLearned is to implement a “maker-checker” protocol.

For many hierachical, command-and-control, authority-conscious organizations, this can be a common #AntiPattern: the head/executive/leader goes offline to create “content”, and nobody reviews it for #sensemaking, #blindspots, or unintended #messaging.

2024-11-29

Do you know those websites that ask you for your username first and then you have to click a button to see the password field?

I finally found the solution for using KeePass AutoType here: Go to the AutoType tab and add an ENTER and a DELAY (in milliseconds).

```
{USERNAME}{ENTER}{DELAY 1000}{PASSWORD}{ENTER}
```

Works like a charm. #Telekom I am looking at you.

#antipattern

Stephan H. Wisselstw@chaos.social
2024-11-19

Who needs switch statements when you can nest tertiary expression 🤣:

return condition1
? result1
: condition2
? result2
: condition3
? result3
…..
: condition999
? result999
: defaultResult;

Just don’t tell. sonarlint #antipattern #java #nodejs

Thiago Bomfimthiagobfim
2024-11-11

High Coupling: The class is tightly coupled to many other classes and components in the system, making it challenging to modify or extend without affecting other parts of the codebase.

Read more 👉 lttr.ai/ATvUo

2024-09-15

@jasongorman The Ravioli Code #antipattern? wiki.c2.com/?RavioliCode

Note that link is on #WikiWikiWeb which has (IMHO) a confusing single-page application user interface. (Sorry @k9ox)

you╭👺+300╭🐈x5╭⁂+3╭(Ⓐ+aunspeaker
2024-09-02
cannot borrow `*to` as mutable more than once (first borrowed in previous iteration of loop)
2024-08-28

As a "normal" user, when navigating to outlook.office.com, what I wanted was a view of my mailbox and calendar.

What I got wasn't quite right. Instead, I had a message saying "You've signed out of your account" and recommending I close all browser windows.

The implication of this wording is that I did this. I did not. This is yet another #antipattern where systems/services gaslight users into thinking they did something wrong.

#grr #microsoft #azure #EntraID

A friendly looking message from Microsoft informing the user that:

"You've signed out of your account. It's a good idea to close all browser windows."
Thiago Bomfimthiagobfim
2024-08-13

The “Cut-and-Paste Programming” refers to a practice where developers reuse code by copying and pasting it from one part of the software to another, often without fully understanding how it works or without considering the context of its new location.

Read more 👉 lttr.ai/ATj57

pablolarahpablolarah
2024-06-27

🟧 The Shadow DOM is an antipattern
by Chris Ferdinandi @ChrisFerdinandi @cferdinandi

gomakethings.com/the-shadow-do

White text on orange background:
The Shadow DOM is an antipattern

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst