Thursday, 15th August 2024
Thursday,
15.8.2024
Parse, don’t validate. A classic that I keep coming back to. The core idea is very simple: instead of validating data and throwing away what you learned, parse it into a more precise type that preserves that knowledge. The rest of your code gets simpler because impossible states become unrepresentable.
Using this pattern well will remove a lot of „if" statements and error handling scattered around the codebase.