liveBook · Manning

Dangling pointer

As explained in API Design Patterns

A dangling pointer is a pointer that refers to a data object or resource that no longer exists.

A dangling pointer is a reference to a data object or resource that no longer exists. In resource APIs, deleting an author while books still store its authorId creates one. section 13.3.2

Deletion policies trade convenience, consistency, and operational cost:

  • Restrict deletion and return an error, preserving references but potentially forcing consumers to delete many dependent resources. section 13.3.2 section 14.3.6
  • Set references to null, avoiding invalid pointers but risking large, slow, or non-atomic update operations. section 13.3.2 section 14.3.6
  • Cascade deletion, or do nothing and leave consumers to handle invalid references; both can trigger substantial downstream effects. section 14.3.6

Deleting a referenced author

Create an author named Michelle Obama, create the book Becoming with authorId set to that author's id, then delete the author. The book now contains a dangling pointer unless the API restricts, clears, cascades, or explicitly tolerates the invalid reference. section 13.3.2

How API Design Patterns covers it

How deep it goes
Defines invalid references, compares four deletion policies, and examines circular references, bulk writes, and deletion avalanches.
Examples
Uses book-author resources, the Becoming example, circular author-book references, and association resources.
What it assumes
Assumes basic resource references and deletion operations while defining how invalid references arise.
What you can do after
Evaluate deletion policies and recognize when an API should return HTTP 412 or tolerate invalid references.
How it connects
Connects dangling pointers with referential integrity, association resources, circular references, and API deletion policies.

Also explained in

Compare how 2 books explain dangling pointer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.