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

Share Code Across Multiple Controllers

Hello.  I have an app with several custom controllers.  I have about 200 lines of apex code that are identical between "CustomControllerA" and "CustomControllerB".  For maintenance purpuses, I ideally would NOT like to have identical lines of code in various controllers - so is there any way that I can share this code between the two controllers?  I thought an extension might work...but my initial research is telling me no.

Thanks in advance.
You can create a different Apex class and put your identical code inside a method in it.

Then,you can use this class in other classes by calling the method and hence you don't need to write identical codes again and again.

Hence,your code would be re-usable too :)