4 ms·
Exactly. The parent post claimed: > Once you are able to comfortably read type signatures, it is trivial to see what a function is supposed to do Typing gives
by 2019-nCoV 6y ago
Exactly. The parent post claimed:
> Once you are able to comfortably read type signatures, it is trivial to see what a function is supposed to do
Typing gives minimal insight into what a function actually "does".
The solution is intention revealing naming, available in all languages.
- int_19h 6y agoNaming is where it starts, but the type signature also carries plenty of information it it, especially once you get to non-primitive types.
- gavinray 6y agoIt doesn't really matter what the function does, if the input and output signatures are Interfaces or Types that have been annotated with JSDoc. You see "Put an object with these properties and types in, get an object of this shape back out." The beauty of types is in this black-box, abstract behavior. You, as a library author, can define an Interface/Contract for the behavior of something completely abstractly, and other people can all use each other's implementations or contribute original ones because they obey the contract. Think about an "Abstract class File, which implements open, read, and write." There are a lot of ways you could write these methods but if your type signatures match the inputs and outputs they're all equally valid with predictable behavior. Design by contract is a beautiful thing.
- keymone 6y agoit matters when the function isn't pure but otherwise contracts are good.