Titan Web Variable Naming Conventions: Global vs Page Variables Done Right

Titan Web Variable Naming Conventions: Global vs Page Variables Done Right

Variables are the nervous system of every Titan Web project. Get the naming wrong and you end up with spaghetti logic that nobody can debug six months later. This guide covers the naming conventions and scoping rules we use on every Titan implementation at Titanixforce.

The Two Variable Scopes in Titan

Global Variables persist across the entire Titan project – every page, every form, every flow can read and write them. Use these for data that must survive page navigation: user identity, record IDs, authentication tokens, and shared state.

Page Variables exist only within the current page. When the user navigates away, they are gone. Use these for temporary UI state: form step index, selected tab, show/hide toggles, and intermediate calculations.

Naming Convention: Prefix Everything

The single most impactful practice is consistent prefixing. When you see a variable name in a condition or Push mapping, you should instantly know its scope.

ScopePrefixExampleUse For
Globalg_g_accountId, g_userId, g_languageCross-page data, SF record IDs, auth
Pagev_v_currentStep, v_showModal, v_tempTotalUI state, temp calculations, toggles

Rules We Follow

  • camelCase always – g_accountId, not g_account_id or g_AccountId
  • Never store PII in global variables – Salesforce record IDs are fine, email addresses are not
  • One variable, one purpose – do not reuse v_temp for different things on different pages
  • Descriptive names over short names – g_selectedOpportunityId is better than g_oppId
  • Boolean variables start with is/has/show – v_isFormValid, v_hasSubmitted, v_showConfirmation

Common Anti-Patterns

Using global variables for page-level state. If a variable only matters on one page, make it a page variable. Global variables add complexity to every page that loads them.

No prefix at all. Six months later, nobody remembers whether “accountName” is global or page-scoped. The debug session that follows costs more than the 2 seconds it takes to type g_ or v_.

Overloading URL parameters into globals. Use a page variable to receive the URL parameter, validate it, then copy to a global only if other pages need it.

Related Articles

Explore Our Services

Need a Titan implementation built the right way? Contact Titanixforce – we apply these patterns on every project.

Scroll to Top