4 ms·
I don't like the dogmatic test driven development appraoch - so here's mine: --------------------- 1. Use a programming language with an expressive statical t
by valenterry 4y ago
I don't like the dogmatic test driven development appraoch - so here's mine:
---------------------
1. Use a programming language with an expressive statical type-system
2. Write only type-signatures for everything that I want to do (using type-holes) and continously compile my code
3. Once I'm finished with #2 and it all compiles, I start implementing all the methods/functions
4. If I can't implement a method because I got the types wrong (e.g. my types say that I will return a number, but in some cases I cannot and have to return nothing or an error) then I change the type-signature and go back to #2
5. If I can implement a method but I'm not sure it will do the right thing (despite compiling) without running it manually to see if it works, then I write one or more unit tests for the method. If I believe that changing the method will easily break it I also write a test. Otherwise I write no tests.
6. Once finished I write some integration tests for what I deem necessary - both positive as well as negative tests.
7. Done
- garethrowlands 4y agoSometimes, I find I need to revisit some type signatures after I've begun to write code. And this can lead to my code not type checking for longer than I'd like. But I can still run my tests if I defer type errors to runtime (they still appear at compile time but as warnings). See (Deferring Type Errors to Runtime)[https://downloads.haskell.org/~ghc/9.4.4/docs/users_guide/exts/defer_type_errors.html https://downloads.haskell.org/~ghc/9.4.4/docs/users_guide/ex...]