3 ms·
IMO, the problem with the original code is not in the way it nests ifs, it's in the bad design. If it is properly nested in a function, user should not ever be
by BerislavLopac 3y ago
IMO, the problem with the original code is not in the way it nests ifs, it's in the bad design. If it is properly nested in a function, user should not ever be None (any user-less behaviour should be in a completely separate execution branch, likely in a different module), while there is no reason for get_balance and credit_amount to ever return None.
- HelloNurse 3y agowithout a context that might make it reasonable, the original code is fairly absurd: where is the error handling? The bad cases of several if clauses should be by far the largest and least obvious portion of the code, not silently omitted and further obscured by hiding branches.
- infecto 3y agoIt really is both but I was attacking the angle of the library and not the overall design.