2 ms·
who are all these people cramming validation into all their crap everywhere? like, i don’t know if im in the wrong line if work or what, but somehow i seem to w
by keeganpoppen 3y ago
who are all these people cramming validation into all their crap everywhere? like, i don’t know if im in the wrong line if work or what, but somehow i seem to wind up with a constructive approach to 99% of problems in “validation land”… it just seems so fake to me. maybe like the declarative versions where you can just say aspirationally that you know by fiat that values are within some bounds… that i think i grok…
it’s not like i don’t throw landmines into the holes where my error cases lie, it’s just so far from my dominant experience in programming. like, “validating”, per se, literally does nothing on its own to get you to a solution. it only exists to tie your hands to your knees so they dont wind up around your back. and that feels kind of charitablec since hands-behind-back is actually fairly useful (at least, it is for fairly broad-shouldered types like yours truly).
- keeganpoppen 3y agoi guess one could take the tack of my argument being strained in the sense that it is as much contra type systems as it is contra “validation”. which is fair and mostly true. but, i mean… have you ever tried to actually use some of these type systems, man? the other day i had to find a way to completely fuck my whole project’s structure just so that i could get a stupid dataclass union type field to bind at an appropriately late time. self-immolation would be far preferable…
- iraqmtpizza 3y agoI wouldn't call this validation (except at the very end). I would call it parsing. In fact it serves the purpose of not having to duplicate the validation code which is centralized in the canonical constructor. public Function(String signature) { this(signature, signature.indexOf('('), TupleType.EMPTY); } public Function(String signature, String outputs) { this(signature, signature.indexOf('('), outputs != null ? TupleType.parse(outputs) : TupleType.EMPTY); } private Function(final String signature, final int nameLength, final TupleType<?> outputs) { this( TypeEnum.FUNCTION, signature.substring(0, nameLength), TupleType.parse(signature.substring(nameLength)), outputs, null, Function.newMessageDigest() ); } public Function(TypeEnum type, String name, TupleType<?> inputs, TupleType<?> outputs, String stateMutability, MessageDigest messageDigest) { this.type = Objects.requireNonNull(type); this.name = name != null ? validateName(name) : null; this.inputTypes = Objects.requireNonNull(inputs); this.outputTypes = Objects.requireNonNull(outputs); this.stateMutability = stateMutability; this.hashAlgorithm = Objects.requireNonNull(messageDigest.getAlgorithm()); validateFunction(); generateSelector(messageDigest); }