This question was asked by the interviewer but I am not able to get answer of it anywhere else.
Question
I have School Class, Student Class and Academy Class. I School Class has all the Student Information but I want to pass List of Students with the relevant information to Academy class.
For. e.g. Student Class has 80 fields but we should only pass 5 fields and restrict every other fields while passing the list of students to Academy.
My answer to this was that we can create StudentDummy Class which will extend Student class and will override getter methods of those fields which we don't want to show and it will return message saying "This property is restricted" and then send List of StudentDummy Objects instead of student objects. For this he said if the fields are multiple then will have to override many getters. Can you please tell me proper Object Oriented Approach of this?
Student
and why is only a subset allowed to be seen byAcademy
? Why doesSchool
"has all the information" instead of the instances ofStudent
themselves; what does that mean? What are the functions in question here and what is their logic; what are you trying to model exactly? – akuzminykh