"In a object oriented static typed language you should declare variables and parameters as broad as possible and return types as narrow as possible"
Taken literally, that is advising I declare all variables and parameters as Object
(or whatever the base class is for a given language). That's clearly nonsense. Also, it is saying that I should not use an interface for a return type when I can use a specific type. That's also clearly nonsense.
There's some sense behind the words, eg in the .NET world, it's better to eg use IEnumerable<T>
instead of T[]
or List<T>
if the collection is simply enumerated via eg foreach
. Generally it's better to use an abstraction type (eg interface) over a concrete type. But that applies for return types from private methods as much as for parameters. So it's still not very good advice.
Finally, the "object oriented" part is irrelevant. Haskell, the functional language poster boy, has no support for OO, but it still supports polymorphism and it's strongly typed. The same "favour an abstraction type over a concrete type" applies there too.
So in conclusion, it's taken some basic sound advice, distorted it and got the message all wrong. So it's not good advice at all.