24
3.2.1.6 Do
Not
Include Atomic Type Names
Atomic or primitive variables are variables that represent data in their simplest form, such as
booleans, integers, floats, and enumerations.
Strings and vectors are considered atomic in terms of style when working with Blueprints, however
they are technically not atomic.
While vectors consist of three floats, vectors are often able to be manipulated as a whole,
and this is the same with rotators.
Do not consider Text variables as atomic, they are secretly hiding localization functionality.
The atomic type of a string of characters is String, not Text.
Atomic variables should not have their type name in their name.
Example: Use
Score, Kills
, and
Description
not
ScoreFloat, FloatKills, DescriptionString
.
The only exception to this rule is when a variable represents 'a number of' something to be
counted
and
when using a name without a variable type is not easy to read.
Example: A fence generator needs to generate X number of posts. Store X in
NumPosts
or
PostsCount
instead of
Posts
as
Posts
may potentially read as an Array of a variable type
named
Post.
3.2.1.7 Do Include Non-Atomic Type Names
Non-atomic or complex variables are variables that represent data as a collection of atomic variables.
Structs, Classes, Interfaces, and primitives with hidden behavior such as
Text
and
Name
all qualify
under this rule.
While an Array of an atomic variable type is a list of variables, Arrays do not change the
'atomicness' of a variable type.
These variables should include their type name while still considering their context.
If a class owns an instance of a complex variable, i.e. if a
BP_PlayerCharacter
owns a
BP_Hat,
it
should be stored as the variable type as without any name modifications.
Example: Use
Hat, Flag,
and
Ability
not
MyHat, MyFlag,
and
PlayerAbility
.
If a class does not own the value a complex variable represents, you should use a noun along
with the variable type.
Example: If a
BP_Turret
has the ability to target a
BP_PlayerCharacter,
it should store its target
as
TargetPlayer
as when in the context of
BP_Turret
it should be clear that it is a reference to
another complex variable type that it does not own.