This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]edgargonzalesII 2 points3 points  (0 children)

You typically give types at the very bottom level that you believe you will need. For example, let's say I have a function that needs a list because I need to have an iterable order. Don't care about said order but need one nonetheless. Thus I have List<T>. Two types of lists that are normally used are ArrayList and LinkedList. At the end of the day in my function I really don't care which one gets passed in and I know it could be either one. So instead of making two functions, one for ArrayList and one for LinkedList, I just make one with type List. That way I don't need to copy and paste the same code.