3 ms·
I find the general point interesting, but want to nitpick: > "items in the deleted state must have a deleted time" I much prefer making it impossible to repre
by kstrauser 3y ago
I find the general point interesting, but want to nitpick:
> "items in the deleted state must have a deleted time"
I much prefer making it impossible to represent bad state, like rephrasing at as "items are deleted if their deleted_time property is set". In this case, that makes the deletion atomic: there's never an instant where it's ambiguous if the object was deleted.
That doesn't disagree with his premise. It's an additional recommendation.
- kartoshechka 3y agosometimes it's not easily achievable, when code is owned by other team or data comes from external source. I guess forbidding invalid state is the best option, and checking invariants is viable choice when you can't avoid invalid states
- magicalhippo 3y agoNot all databases optimize NULL columns, so searching for items that aren't deleted might be a table scan worst case. I speak from hard-earned experience... In such cases I fall back to computed columns. A deleted flag which value depends on deleted_time being set or not, for example. This retains your atomic state goal.
- myvoiceismypass 3y agoReminds me of the old blog post with the phrase “Make illegal states unrepresentable” https://blog.janestreet.com/effective-ml-revisited/ https://blog.janestreet.com/effective-ml-revisited/ (Yaron Minsky)