Refactoring towards the Liskov Substitution Principle

January 4, 2015

Sometimes you write or encounter a method that return an object that represents a complex result upon which the caller should decide how to proceed. For example, consider the method with the following signature: StudentQueryResult FindStudent(string nameSubstring); This method looks for a student by his name or part (substring) of it. This method can have 3 possible return values: 1. If there's no student found that matches the substring, it should return null 2. If there's exactly one student that matches the substring, it should return all of the details about this student, including the list of courses he completed and the...