very simple problem, but i want to see how experts look at it.
This is just imaginary software just to understand OOP.
I have a school administration software. So I have classes
- Student
- ClassRoom
- Teacher
Now I assign a teacher as class-teacher for a particular classroom. Thus
ClassRoom contains
Teacher classTeacher;
Student[] students;
Now the complete program is written and everything works fine …
Problem:
Now what If the principal puts a new rule, that there should not exist a student to whom the Teacher is the Parent.
Now we need to bring more parameters and lot of changes in our code for a small requirement.
How should the design be in order for future changes in requirements (which will inevitably come) to only require minor changes in the code?
This should not be a big code change, this should be a validation change.
Psuedo-Code:
Sure you are going to have to go into the database and the codebase and add “Parent” properties to all your students. But that also shouldn’t be too hard.