Hacker News new | past | comments | ask | show | jobs | submit login

Re: trust issues...I'd argue this is the purpose of automated tests. I think tests are too often left out of architectural discussions as if they are some additional artifact that gets created separately from the running software. The core / foundational / heavily reused parts of the architecture should have the most tests and ensure the consumers of those parts has no trust issues!



Tests are good but moving left by lifting invariants into the type system is better.

Compare

   fn send_email(addr: &str, subject: &str, body: &str) -> Result<()>
to

    fn send_email(add: &EmailAddr, subject: &str, body: &str) -> Result<()>
In the second case, the edge cases of an empty or invalid email address don't need to be tested, they are statically impossible.


Thanks for the small concrete example. I try to explain this a lot. It also makes coverage really easy to get with fewer tests.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: