May 2nd, 2014
In Technology
No Comments
If you enjoy this article, see the other most popular articles
If you enjoy this article, see the other most popular articles
If you enjoy this article, see the other most popular articles
Design by contract in Clojure
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.
I have gotten in the habit of doing 2 things:
1.) I used :pre and :post conditions as you are doing here
2.) I also use dire so when the :pre or :post conditions fail and an Assert exception is thrown, I can capture the arguments and the return value and write a meaningful error message:
https://github.com/MichaelDrogalis/dire
I do a lot of this:
:post [(:discount %)]
I also test for value ranges:
:post
[
(> (:totals %) 100)
(< (:totals %) 1000)
]
I am thinking I might use prismatic/schema in the future.
Post external references
- 1
http://theholyjava.wordpress.com/2014/04/30/clojure-how-to-prevent-expected-map-got-vector-and-similar-errors/#comment-6648
February 8, 2022 9:33 am
From Michael S on How I recovered from Lyme Disease: I fasted for two weeks, no food, just water
"Did you have Bartonella, too? Seems it uses autogenesis..."