Home
Blog
Single Source of Truth
Updated
Dot Net Perls

Single Source of Truth

One important principle in program design is having a single source of truth for a specific program state. So if you have several ways of determining if a Page is a Blog page, this can get confusing and result in bugs.

Instead, you should have just one place where the Page type is stored, and access it in a uniform way through the program. This principle is called the "single source of truth" and is well-known in computer science. It can be applied to many situations, including:

Programs (like with the Page example).
Databases, where only one table returns the result (rather than many tables).
More complex systems with multiple programs and databases.

As always, using caches to speed up access to this information can be problematic, as the cache ends up copying the single source of truth. Even when writing a simple program, relying on a unified, single source of truth is helpful.

Dot Net Perls is a collection of pages with code examples, which are updated to stay current. Programming is an art, and it can be learned from examples.
Donate to this site to help offset the costs of running the server. Sites like this will cease to exist if there is no financial support for them.
Sam Allen is passionate about computer languages, and he maintains 100% of the material available on this website. He hopes it makes the world a nicer place.
No updates found for this page.
Home
Changes
© 2007-2025 Sam Allen