Naming in global namespaces

Defensive prefixing for names that land in a namespace we do not control

Id general-naming-global-namespaces Applies to any Status active Enforceable yes, no check yet Tags namingglobal-namespaceprefixing

Sometimes we need to execute code in a global namespace in PHP or JavaScript, or key data in databases and caches in environments we don’t control.

Common database keys like api_url, plugin_config or system_status could be set by another codebase, so we need to be defensive with our naming.

General best practice

Examples

The notable exception is something well-prefixed where the nfd is overly verbose:

wp-plugin-bluehost-admin is a fine asset handle, an nfd- prefix is overkill.