3 ms·
Also, how does full unit (!) test coverage prevent a situation where unit A passes some type to unit B that unit B doesn't expect but happily runs with, but wit
by mike_hock 11y ago
Also, how does full unit (!) test coverage prevent a situation where unit A passes some type to unit B that unit B doesn't expect but happily runs with, but with different semantics?
Documentation of interfaces in dynamic languages usually always specify the types of arguments and return values, and the code very often looks like this:
def foo(arg)
raise TypeError, "Integer argument expected" unless arg.kind_of?(Integer)
# ...
end
Yup. That saved me a lot of typing (no pun intended) compared to
void foo(int arg) {
// ...
}
Reading (and writing) code in dynamic languages (including the tests!) always seems to me to disprove all of their purported benefits and underlines the need for a strong type system.
- spion 11y agoYup, the right tool for the job. Type systems are really good at enforcing inter-unit contracts, while tests (especially property tests) are very good at making sure that the implementation is correct for at least a subset of inputs.