3 ms·
> but I have found that nothing is as important as tests when refactoring You don't need those with static types. You only need to write tests for your actual
by incepted 11y ago
> but I have found that nothing is as important as tests when refactoring
You don't need those with static types. You only need to write tests for your actual code, not things that the compiler can check for you.
Manually writing code to check things the computer can test for you is a waste of developers time.
- yrro 11y agoThe type system only goes so far. If your refactored code calls functions that take several different parameters of the same type, you can make mistakes that the compiler won't catch.
- echelon 11y agoIn some sense, taking several parameters of the same type can be a code smell. Foo(str, str, str) strikes me as somewhat suspect. I realize this isn't always avoidable, but a lot of the time it is.
- actsasbuffoon 11y agoThere are workarounds for this kind of thing. Haskell uses newtypes to wrap a value with a semantically meaningful tag. Scala has a similar concept called "value types." That means you could turn something like this: loginUser(String, String) Into this: loginUser(Username, Password) These aren't just type aliases. So far as the language is concerned, Username and Password are incompatible types.