Smart Constructors
More from Andy G's Blog
(Featured image by Camille Couvez on Unsplash) When a measure becomes a target, it ceases to be a good measure But AndyG, doesn’t this just encourage a race to the bottom? Aren’t we sacrificing quality for speed?
His HolinessCasa Santa Marta00120 Vatican City
“I’ll compose a new type that holds a Doohickey and also indicates whether the fetch operation succeeded!” If you couldn’t have a utopia in the real world, then dammit you’d have one in your obscure codebase! It shall have clean logic untarnished by dirty, filthy hobbitses error-checking. Something like this:
If there’s an if condition inside a function, consider if it could be moved to the caller instead Finally, I want to briefly return to the notion of testing: Well, the answer to that is the same as the answer to exceptions; strengthen the type returned by the function, and let callers ignore scenarios they […]
Cars People 0 0 1 1 2 4 3 9 4 16 5 25 Number of people on the first N train cars