+ Start a Discussion

Apex character limit - Hardcode or variable?


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?


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.