3 ms·
To me, by far the biggest advantage of generics is that it makes it a whole lot easier to understand function signatures. I develop on both Android and iOS and
by entropy_ 12y ago
To me, by far the biggest advantage of generics is that it makes it a whole lot easier to understand function signatures. I develop on both Android and iOS and I can't even begin to count the number of times I've read a function definition, seen that it takes an (NSArray *) as a parameter and had to trudge through 5 layers of indirection(either upwards to find the construction, or downwards to find the use) to figure out what that array is supposed to be filled with. Contrast that with Java on Android, if a function takes a List I can immediately tell what type of list it's expecting. It's true that if the code had proper tests and a good architecture this shouldn't be an issue, but when was that ever the case? You just get handed a git repo your predecessor left and are expected to read the code and understand it.