Engrain by ByteRush

TS.07.03 Mid-level

Branded types and nominal patterns

Comes up in: Coding, Low-level design

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • brands with unique symbols
  • UserId vs OrderId
  • smart constructors with validation
  • opaque types for money/units

Words you will know

branded typenominal typingsmart constructor

What you will practise

  • prevent mixing currency amounts

Interview questions this answers

  • What is a branded type and why would you use one?