[HN Gopher] Don't Use Booleans
___________________________________________________________________
Don't Use Booleans
Author : pavel_lishin
Score : 15 points
Date : 2024-07-03 15:45 UTC (5 days ago)
(HTM) web link (www.luu.io)
(TXT) w3m dump (www.luu.io)
| pavel_lishin wrote:
| Folks, the headline is real bad and clickbaity, but I think the
| blog post is actually very, very correct in its basic premise.
| compressedgas wrote:
| Reminds me of https://blog.ometer.com/2011/01/20/boolean-
| parameters-are-wr...
| 0x63_Problems wrote:
| I'm definitely a fan of making bad data 'unrepresentable' through
| the type system. The bit flag enum pattern is not so familiar to
| me in Python, but I recognize it from the CPython internals so
| maybe it's more common in systems languages. Not sure how I feel
| about explicitly listing every valid combination of flags, but
| I'm sure in some cases that's the right move.
| kierenj wrote:
| Solution in C#: use named parameters: RaiseInvoice(taxInvoice:
| false, sendEmail: true)
| 2OEH8eoCRo0 wrote:
| Why not a comment that explains what the args are? I like enums
| but you're basically cramming information that should be in a
| comment into enums.
___________________________________________________________________
(page generated 2024-07-08 23:00 UTC)