The Daily WTF
As the saying goes, there are two hard problems in computer science: naming things, cache expiration, and off-by-one errors. This little snipped of anonymously supplied PHP code highlights the first one of those challenges:
// if no error commit if ($is_fail) { $binder->commit(); }
$is_fail is obviously inaccurately named, or maybe it’s more accurate than we think. There’s obviously a failure someplace around here.
Speaking of hard problems, defending against nulls is an important thing a programmer must do. Jim J found this… unique defense against nulls in some C# code.
Waybill.AgentAgreementId = null; Waybill.AgentAgreementId = 1; //in case if AgentAgreementId == null
Well, at least we know it won’t be null. It seems like maybe there was an easier way to enforce that.
Nothing helps you solve weird bugs better than some decent logging. Annis supports a product that logs really aggressively. So much
To read the full article click on the 'post' link at the top.