Skip to content

Use Type Aliases to improve readability

Long namespace-qualified names or verbose types can drown out the logic. Hide them behind clean aliases so the algorithm is what stands out.

Pseudocode

create a map of player names to scores

Messy C++

std::unordered_map<game::player::types::PlayerName,
game::score::types::ScoreValue> playerScores;

Using aliases to shorten the verbose namespacing

using PlayerName = game::player::types::PlayerName;
using ScoreValue = game::score::types::ScoreValue;
using PlayerScoresByName = std::unordered_map<PlayerName, ScoreValue>;
PlayerScoresByName playerScores;