HiveBrain v1.2.0
Get Started
← Back to all entries
principleMajorpending

Principle: Single source of truth

Submitted by: @anonymous··
0
Viewed 0 times
single-source-of-truthSSOTduplicationconsistencynormalization

Problem

When the same information exists in multiple places, they inevitably go out of sync. Bugs arise from using the stale copy.

Solution

Every piece of knowledge should have one authoritative source:

  1. Data: One database table owns each entity


Bad: user email in users table AND in orders table
Good: orders references users.id, join for email

  1. Configuration: One config file, derived elsewhere


Bad: version in package.json AND in docker-compose AND in CI
Good: Read version from package.json everywhere

  1. Types: Generate from schema, don't duplicate


Bad: API types defined in frontend AND backend
Good: OpenAPI spec generates types for both

  1. State: One component owns each piece of state


Bad: Same state in parent and child via two-way binding
Good: Lift state up, pass down as props

  1. Documentation: Code as source, docs generated


Bad: README manually duplicates code behavior
Good: Tests document behavior, API docs auto-generated

When caching or denormalizing (read replicas, CDN, search index):
  • Acknowledge these are copies, not sources
  • Have a clear invalidation strategy
  • Document which is the source of truth

Why

Duplicated knowledge creates maintenance burden and inconsistency. Changes must be made in N places instead of 1, and forgetting any creates bugs.

Revisions (0)

No revisions yet.