WorkspaceLow-Level Design
← Course overview

Course navigation

On this page

Low-Level Design / Interview Preparation

reading · 8 MIN READ

Entity Identification

An entity has an identity that persists as its attributes change. A value is usually described by its contents. Distinguishing them clarifies equality, ownership, and lifecycle decisions.

Reading completion is independent of quizzes and challenges.

What you’ll understand

  • An entity has an identity that persists as its attributes change. A value is usually described by its contents. Distinguishing them clarifies equality, ownership, and lifecycle decisions.
  • Practice explaining a design decision with an example and a boundary case.

Extract more than nouns

In a library, BookTitle describes shared catalog information while BookCopy identifies one lendable physical item. A Member can change their name without becoming a different member. A Loan records a relationship with its own dates and lifecycle. Not every noun in a requirement deserves a class.

  • Ask what must be distinguishable when values are equal.
  • Identify what can change without changing identity.
  • Separate shared metadata from individually managed instances.

Assign operations to the invariant owner

An operation belongs near the state whose validity it protects. A loan workflow may coordinate several objects, but a copy’s availability rule should not be duplicated in every caller. Use a service when a meaningful use case spans several owners.

  • Write the invariant in one sentence.
  • Name the state that proves or violates it.
  • Choose one place to enforce it.

Test the model with counterexamples

Imagine two books with the same title, two customers with the same name, or two notifications with the same payload. Decide which are the same entity and which are merely equal values. The answer affects lookup keys, deduplication, and update behavior.

  • Should renaming a customer change their booking links?
  • Can a line item belong to two orders?
  • What key identifies a retried operation?

Further reading

Original StackSim lessons and examples. These references provide additional background.

Make it your own

Saved on this device · 0/20,000

Reading completion is independent of quizzes and challenges.