3 ms·
In imperative programming, your code can execute in two states, valid and not-valid. You start in valid state, then any validation failure returns you to non-va
by nercury 12y ago
In imperative programming, your code can execute in two states, valid and not-valid. You start in valid state, then any validation failure returns you to non-valid state and you remain there. Pretty much the core of any validation technique without bells and whistles.
valid = true
if valid and not check1():
valid = false
if valid and not check2():
valid = false
...
- TheLoneWolfling 12y agoI much prefer the (equivalent) code: if not check1(): return false if not check2(): return false ...