News for hackers. Stuff that matters.
Re:Make Invalid States Unrepresentable by hnbad on Thursday April 25, 2024 @04:34AM (#40154959)
I second this as I find that usually the solution that is the most mathematically pure is usually also the one completely inadequate at handling the complexities of real-world applications and end up having various extremely impure additions bolted onto them (as shell scripts or Excel spreadsheets on a shared network drive if necessary) because refactoring them into an equally pure solution for the real-world case would take too long.
Re:Make Invalid States Unrepresentable by frandroid on Thursday April 25, 2024 @05:51AM (#40155441)
Okay but the solution here is to identify and parcel your cases into discrete entities. The article doesn't say "don't accept anything odd", it says "clearly identify what you accept". If you have to accept odd cases, identify them so it's clear what's happening.

So this isn't about purity, it's about being declarative. i.e. make your code say what it accepts, instead of writing board/implicit acceptable inputs that inevitably forget cases and crashes.

If you limit what you accept as inputs then you can stop worrying about downstream error handling and debugging.