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
CvrKCvrK 

Best practices of apex conteollers and bach apex considerations not jist triggers?


Hi 
i am at beggining stage of development Interested to know about best practices of apex controller, best practices and considerations for batch apex not just triggers,i have searched alot but only found the references for apex triggers not on controllers and batch apex.
below are my doubts that made me post here:
1)i got a convincing answer while reading about the difference between controllers and extensions 

The answer which i read says "controllers  can exist with or without parameterized constructors but extensions must have parameterized constructors" then
My doubt is why cant i have both parametered and non parameterized constructors in one controller instead of having an extension to my custom controller particularly when i use custom controllers with extensions not referring to the usage of standard controllers with extensions?


James LoghryJames Loghry
Here's a great place to start for general best practices: https://developer.salesforce.com/blogs/developer-relations/2015/01/apex-best-practices-15-apex-commandments.html

Another place to get tips, etc is to start doing trailhead modules, especially around th Visualforce and Apex related trails.  Trailhead can be found here: http://developer.salesforce.com/trailhead
JeffreyStevensJeffreyStevens
In answer to your second part of the question - I don't use a controller extensioin with a custom controller.  I only use an extension when I'm using the standard controller.