You need to sign in to do that
Don't have an account?
Steve Berley [Left Propeller]
writing generic code - how to abstract/dereference a variable to subject type
I'm writing some generic code and want to refer to an sobject type using a variable. The goal being to write code similar to ...
Can this even be done in apex?
Thanks,
string t = 'custom_object__c'; list<t> objs = new list<t>(); // creating a list of custom_object__c'sOf course, string is not the right type for t, but thi sis the idea I'm trying to accomplish
Can this even be done in apex?
Thanks,
Apex considers the concept of "dynamic apex" for genericity.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic.htm
More generally: the new way of writing the classes and triggers in Salesforce is to use the concept of separation of concern (service layer principles, domain and selector layor and unit of work among other thing)
https://trailhead.salesforce.com/module/apex_patterns_sl
https://trailhead.salesforce.com/module/apex_patterns_dsl
Regards
Alain