The reason why we use constructors in any OO language - to initialize class variables and perform some basic computation. In case of controllers, we can use it run a query or calculate a value or if a particular field on the page has to be rendered or not and so forth.
Note that to make DML operations we need to use a method attached to the action attribute of the page - this is a salesforce restriction
The reason why we use constructors in any OO language - to initialize class variables and perform some basic computation. In case of controllers, we can use it run a query or calculate a value or if a particular field on the page has to be rendered or not and so forth.
Note that to make DML operations we need to use a method attached to the action attribute of the page - this is a salesforce restriction