function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC_LearnerSFDC_Learner 

Constructor limits

Hi

 

Can any one give me a list of points that we should not do with in constructor?

 

i know few like,

 

-> we should not do DML operations.

 

can you give more tips ?

sfdcfoxsfdcfox
As far as I am aware, the only thing you cannot do is DML in a constructor. In prior releases, it was not permitted to perform any callouts, but that restriction is no longer true.
Deshraj KumawatDeshraj Kumawat

The only limit I am aware of is you can not use DML statements in apex class constructor. Apart from this if you are using the same apex class as controller/extension for multiple pages, you can use initialize method (action function, will be invoked from page using the action attribute) to seperate the code for each visualforce page, this will avoid the execution of unnecessary code and will increase the performance.

 

I beleive below links can help you:

 

http://boards.developerforce.com/t5/Apex-Code-Development/Best-Practices-Constructor-or-Initialization/td-p/222271

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_additional_controller.htm

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

 

Thanks

Deshraj Kumawat