It's better to abstract arrays through the use of more sophisticated classes like IList in .NET, which can mitigate the issues with traditional primitive arrays and provide developers with something that works better in modern multi-core scenarios.
It's better to abstract arrays through the use of more sophisticated classes like IList in .NET, which can mitigate the issues with traditional primitive arrays and provide developers with something that works better in modern multi-core scenarios.
Return IList instead of List on any public interface you define is the rule I try to obey.
Basically it's all about how you implement arrays in your called classes - do they expose some internal state by returning a deep clone of the array each time it's called (which is what the examples Eric used were doing) or does it expose its contents via a read-only List?
1) Don't give a reference to your mutable private/shared variables because it's dangerous.
2) Because we still need to let people read this data, give them copies (of a potentially large structure) instead and lose performance.
It just happens to be that arrays are a common case.