appthem is based in SE Melbourne

Tel: 0425 703 597

Show in Google Maps

Why pass collections as their interfaces?  (soliD)

Give careful consideration to how you pass around collections. Try not to tie parameters and return values to their implementation classes. Specify them as interfaces and release your code from this dependency.

When passing parameters, always select the most primitive interface, eg.

If your collection parameter is going to be read in order (it’s only used in a foreach or otherwise doesn’t need random access), pass it as IEnumerable<T>.

If your collection parameter will be changed or needs random access, pass it as ICollection<T>.

Why? You’re removing the dependency and you’re also making your method more flexible giving the caller the ability to pass any kind of collection which implements that interface.