Activity › Forums › Salesforce® Discussions › Why we can't perform DML operations in Constructor? › Reply To: Why we can't perform DML operations in Constructor?
MemberAugust 11, 2016 at 4:09 pm
Using insert/update/delete in constructor is a bad practice in any language.
Establishing connection to DB - OK.
Constructor is used to create an object and initialize it's parameters; nothing more.
1. Using DML in constructor will slow down initialization of your object.
2. It may fail and object just doesn't create at all.