That\'s kind of a general question (but I\'m using C#), what\'s the best way (best practice), do you return null or empty collection for a method that has a collection as a
Depends on your contract and your concrete case. Generally it's best to return empty collections, but sometimes (rarely):
null
might mean something more specific;null
.Some concrete examples:
null
would mean the element is missing, while an empty collection would render a redundant (and possibly incorrect)