4 ms·
Imagine you have a non-generic function, for example, `parseJsonData(string)`, how would you understand how it is being used? It can be called with all sorts of
by protomolecule 7y ago
Imagine you have a non-generic function, for example, `parseJsonData(string)`, how would you understand how it is being used? It can be called with all sorts of input.
Is the problem you are describing different?
- baby 7y agoThat’s true. Usually the name of the argument indicates how it is used. Without it you are lost. I feel like what really tricks me is this kind of code: parseJsonData(t T) Now neither the type nor the argument name help you understanding the purpose of the function.
- protomolecule 7y agoIn this case wouldn't the name of a contract be enough? Or, perhaps, not enough, but informative to the same degree?
- spion 7y agoThe one-letter "naming convention" used for generic types by most developers is very unfortunate.
- protomolecule 7y agoWhy? There are usually only one or two of them, it's like using `i` for loops instead of `indexOfElement`.
- spion 7y agoType parameters are more like function arguments, not loop variables. There is often one or two arguments too but they are not as local (contained) as loop variables.