Parse, don’t validate
ARANK

Historically, I’ve struggled to find a concise, simple way to explain what it means to practice type-driven design. Too often, when someone asks me “How did you come up with this approach?” I find I can’t give them a satisfying answer. I know it didn’t just come to me in a vision—I have an iterative design process that doesn’t require plucking the “right” approach out of thin air—yet I haven’t been very successful in communicating that process to others.However, about a month ago, I was reflecting on Twitter about the differences I experienced parsing JSON in statically- and dynamically-typed languages, and finally, I realized what I was looking for. Now I have a single, snappy slogan that encapsulates what type-driven design means to me, and better yet, it’s only three words long:Parse, don’t validate.The essence of type-driven designAlright, I’ll confess: unless you already know what type-driven design is, my catchy slogan probably doesn’t mean all that much to you. F…

lexi-lambda.github.io
Related Topics: X as a Service
1 comments
  • 今の zod の中核にある考え方で、 parse don't validate という概念について解説した話。インスタンスに状態をもたせて同じ型を使い回すのではなく、その状態に合わせた型がパースされて変換されていくイメージ。型駆動開発。 / “Parse, don’t validate” htn.to/2tcrmgDXiB