I think I remember reading somewhere that one of the principles of good OO design is to write methods which take the least derived type possible, but return the most derived type possible? First, is there such a principle and second, what name would it go by? I'm looking for the name so that when I mentor other developers I can refer them to it.
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
|
|
This seems to be a variant of Postel's Law, also called the Robustness Principle:
|
|||||
|
|
I don't remember the "name" for this principle but it certainly exists and is much more general than only OO. The basic idea is to be lenient on what inputs you accept (so you can accept input from more sources) and stringent on what outputs you produce (so others have to go through less trouble to use it) |
|||
|
|