Skip to main content

03 / 16

Naming

Follow Unreal's prefixes and PascalCase. Put units and boolean meaning in the name.

Unreal's tooling, reflection, and APIs all assume the prefix conventions. Beyond that, a name has one job at the call site: say what the value is without making someone open the header.

Type prefixes

AAActor descendantsACharacter, AProjectile
UUObject descendants that aren't actorsUActorComponent, UItemDefinition
FStructs and most plain C++ typesFVector, FInventoryEntry
EEnumsETeamAttitude, EWeaponState
IThe native half of an Unreal interfaceIInteractable
SSlate widgetsSCompoundWidget
TTemplate typesTArray, TSharedPtr

Rules

  1. 01Boolean fields begin with b. Boolean queries ask a question, such as IsAlive, HasAuthority, or ShouldRespawn.
  2. 02Procedures use a specific verb such as EquipWeapon or RemoveExpiredEffects. Vague verbs such as HandleData and ProcessItems rarely explain the effect.
  3. 03Written output parameters begin with Out. A boolean output places b first, such as bOutWasAdded.
  4. 04Include units when the type cannot express them: DurationSeconds, DistanceCentimeters, and AngleDegrees.
  5. 05The larger the scope, the longer a name can afford to be. A two-line local does not need the same context as a public subsystem method.
  6. 06Project macros use uppercase words, underscores, and a project prefix. Engine macros use UE_.
  7. 07An Unreal interface declares two types: a U-prefixed UInterface class that exists for reflection, and an I-prefixed native class that holds the functions. Implementations inherit the I version.
  8. 08Keep abbreviations to the ones the engine already uses, such as Idx and Num. A project-specific shortening costs every new reader a lookup.
  9. 09A boolean name states what true means. bIsVisible answers a question; bVisibility leaves the reader guessing which way the flag points.
  10. 10Reserve Get for a cheap accessor. A Get that runs a search or allocates misleads the caller about cost, so name it Find, Compute, or Build instead.
  11. 11Name the concept, not the container. ActiveEffects still reads correctly after a change from TArray to TSet. EffectArray is wrong as soon as the type changes.

All 16 rules