Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Update StringBuilder.cls #9

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Update StringBuilder.cls #9

wants to merge 6 commits into from

Conversation

scolladon
Copy link

String list support in order to low the cpu consumption when creating the string

String list support in order to low the cpu consumption when creating the string
String list support in order to low the cpu consumption when creating the string
Conflicts:
	df12/src/classes/StringBuilder.cls
@afawcett
Copy link
Contributor

Thanks for this contribution!

However there are a couple of things that prevent me merging this unfortunately...

Firstly this repo is no longer used to manage the latest apex enterprise patterns library, it was retired and instead as per the readme the latest library is moved to https://github.com/financialforcedev/fflib-apex-common. My aim is to keep this repo the same as per the presentations in 2012.

Secondly, while i can see what your wanting to do, and I'm curious as to your uses cases and motivations? As it stands it does I am afraid make me feel that it could lead to bad programming practices and also odd behaviour in the calling code. Queries, like DML, should not be performed in loops or over and over, so if the same query needs to be made twice or more in one execution context it's usually a code smell for a poor optimisation or design (though as with all things there can be exceptions of course). Also your logic does not currently take into account variances in the variables used in the criteria, so while the SOQL string maybe the same between two calls, the variables / filter values might be different.

Can i suggest that you raise a GitHub Issue over in the main repo, to discuss the use cases and requirement you have and we can brainstorm together? 👍

https://github.com/financialforcedev/fflib-apex-common/issues

@scolladon
Copy link
Author

Hello Andrew,

Thanks for your analysis.
You're right, we should not have to memoize query result as this is a bad practice to repeat the same query in the same context and Salesforce probably cache this kind of queries.
We faced the problem because we have a complex hierarchy of sharing which we have developed as a domain layer. This layer is called many times in the same context if we touch to many layer of our data and does exactly the same queries. So, to avoid SOQL governor limit hit we implemented this memoization layer.

I do not understand you point for the variable/filter. If the query is a string, it contains every filter and variables stringified in my point of view. The only limitation should be the sharing but in the same context it does not apply I think.

I did not see the second repo, thanks for the information. :)

@afawcett
Copy link
Contributor

Your welcome! Regarding the point on variable/filter, i was thinking of a query like this 'Select Id from Account where Ids in :myIds', as a string form the query matches. However the contents of 'myIds' would be different between each call. If your not using variables in your queries then your code is fine.

@scolladon
Copy link
Author

Ok,

I was rather thinking about dynamic SOQL query construct explicitly like
Select Id from Account where Id in ('xxxxxxxxxxxxxxx',..,'xxxxxxxxxxxxxxy').
In this case this ok I think.
Thanks for having shared the other repo, this is just amazing. Do you know
where I can find tuto/diagram helping to understand the global architecture
? It will really help understand how to apply it in my job.
:)

On Thu Feb 19 2015 at 14:14:23 Andrew Fawcett [email protected]
wrote:

Your welcome! Regarding the point on variable/filter, i was thinking of a
query like this 'Select Id from Account where Ids in :myIds', as a string
form the query matches. However the contents of 'myIds' would be different
between each call. If your not using variables in your queries then your
code is fine.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@afawcett
Copy link
Contributor

Your very welcome, check out the links in the README to various Wiki and my own blog entries.

@scolladon
Copy link
Author

Bonjour financialforcedev/df12-apex-enterprise-patterns,
Sebastien Colladon vous a laissé un message sur IQ Elite
Cliquez ici a.iqelite.com/j/z8pJaH/az7/?hg=BLWDpeq7cT pour lire votre message

L'équipe d'IQ Elite


Ce message est destiné à [email protected]. Si vous ne souhaitez pas recevoir d'autres messages de la part de IQ Elite, veuillez cliquer sur ce lien : a.iqelite.com/common/unsubscribe/?code=19cfad4d&email=[email protected].&hg=BLWDpeq7cT

IQ Elite est un service de IQ Elite S.L., dont le siège se trouve à : C/ Gran De Gràcia 15, 1a 1a, 08012 Barcelone, Espagne.

@afawcett
Copy link
Contributor

afawcett commented Jul 4, 2016

Sorry @ForceComDeveloper i don't understand your last message?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants