Skip to content

Apex Consts

The Constants Framework provides a structured approach for managing constants in Apex.

API version

License

GitHub Repo starsGitHub Release

What Does It Solve?

  • Variables Scattered Across Codebase - The same constant values duplicated in multiple places.
  • God Class - A single massive class containing all constants becomes hard to maintain.
  • Code Performance - Loading all constants at once, even when unnecessary, impacts Apex heap size.

Why Apex Consts?

  • Request and Cache - Only necessary consts are saved in Apex memory.
  • Consts Modules - Separated const classes per sObjectType or business logic. No more God class.
  • Consts Entry Point - Access all your consts via the Consts class.
  • English-like Notation - Make your code clean with English-like notation: Consts.ACCOUNT.TYPE.PROSPECT.

Quick Start

apex
Account acc = new Account(
    Name = 'My Account',
    Type = Consts.ACCOUNT.TYPE.PROSPECT,
    Rating = Consts.ACCOUNT.RATING.HOT
);

Documentation

Installation