Journal 2022-07-14

<!-- Morning -->

DRY and SPOT

Somewhere on Twitter I read an interesting argument made on HN. It was arguing for a better principle than DRY (Dont Repeat Yourself).

The SPOT (Single Point Of Truth) is similar to DRY, but I believe it provides a more easy to reason with and refactor architecture to a codebase.

An easy way to implemented it in a MVC architecture is to create an Handler for a Model where the Model acts only as a DTO and the Handler does the editing.

This design patter could fell short since the Model has to reflect the database structure and you can say there is no SPOT since the truth must be both in the database and in the model, but its easier to refactor a data change than a logic change. For example editing a column type is easier than changing the way you log things everywhere.

The DRY principle is still valid and good, but I usually stand by the 3 times rule: you must do something the same way three time before creating a more general abstraction.

<!-- What do I want to do today? --> <!-- Evening --> <!-- What did I learn today? --> <!-- Things I learned --> <!-- Useful tools and libraries -->