BP10: Return interfaces instead of concrete types

Almost always return an interface type and return the most generic one making sense for the typical consuming code.

Comments

Anonymous
You never know what an interface type is hiding.
Anonymous
I'd disagree and say: Always return conrete Types but only accept interfaces (where appropriate, eg. public methods). This way you don't limit your users but still manage to have lose coupling.
Anonymous
Don't always blindly return interfaces instead of concrete types. Understand the difference and the implications, then choose depending on your requirements.

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play