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
sunny.sfdcsunny.sfdc 

Apex character limit - Hardcode or variable?

Hi

Apex has character limits in Salesforce. I have a constant which I want to use in my code in number of different places. So I stored this constant in a separate class and used wherever it is required in code.
For example if I take a constant value in a variable:
public static final String BLANKSPACE = 'hi!';
However harcoding occupies only 3 characters but assigning it to a variable and then using variable occupies a lot more characters. How apex code character limit is justified in the above case?

TIA

 
Chris  ByromChris Byrom
This is a normal pattern for storing constants. Unless you are running into or close to the character limit for Apex, I would not worry about it. If you are, you might contact SF to see if they can up the limit for your org.