News for hackers. Stuff that matters.
Re:Parse, Don’t Validate by james_s_tayler on Thursday November 07, 2019 @11:45PM (#21480027)
Do you have any resources you can recommend which describe how to create an algebra of a domain?
Re:Parse, Don’t Validate by jen20 on Friday November 08, 2019 @01:32AM (#21480371)
I’d recommend Scott Wlaschin’s excellent book “Domain Modelling made Functional”. The examples are in F# but the concepts apply much more broadly.
Re:Parse, Don’t Validate by kuroguro on Friday November 08, 2019 @07:17AM (#21481563)
Re:Parse, Don’t Validate by q-base on Friday November 08, 2019 @11:49AM (#21484015)
Thanks a lot for that video. Watched the whole thing on the spot. He is actually quite a good presenter and really gets the points across.
Re:Parse, Don’t Validate by smush on Friday November 08, 2019 @11:29AM (#21483765)
Came here to post this. I second this book heartily. If you design your types to be DD with raw, valid, invalid data then by the time you actually get to the database or API, you are sure that your code has passed through however many compile-time enforced validity checks (if you use F# or similar static strong type PL) before it got to this point.

That way, you don't need nearly as much defensive coding re: null checks etc. because the data has gone from 'some client typed some value in an input box, hope its valid' to 'this is an Address line that has been confirmed to be valid structure to pass to downstream systems'.

Pit of success is so much better than peak of success, and much easier to get in a static typed functional language vs. an OO language in my experience.

Re:Parse, Don’t Validate by goostavos on Friday November 08, 2019 @01:48AM (#21480416)
+1 for that book. It totally changed how I thought about types and their role in programming.
Re:Parse, Don’t Validate by monoideism on Friday November 08, 2019 @07:02AM (#21481499)
Agreed. This is a great book. It's changed the way I use statically-typed functional languages.

This article is very much in the same vein.

Re:Parse, Don’t Validate by tigershark on Friday November 08, 2019 @02:04AM (#21480454)
The best thing is that he writes F# in a way that is perfectly understandable by the domain experts so he can use the code as the ubiquitous language. In this way an intermediate representation to communicate with the users is not needed and there is nothing that needs to be kept in sync with the code.
Re:Parse, Don’t Validate by james_s_tayler on Friday November 08, 2019 @03:27AM (#21480697)
Thanks!