I often wish law was written more like a computer program, with lots of unit tests up front. But I have no idea how to actually achieve that. Real life is so much more complex than input to any computer program that an attempt to formalise law even more than it already is formalised would just result in it being totally incomprehensible to the people who have to follow it (as opposed to mostly). Plus the man on the street tends to get very angry when people who are "obviously" guilty get off on a technicality.