If these two private functions break LoD.
private Grades getGradesForYear( int year ) private Teacher getTeacher( int year )
Students do not need logic to perform such tasks.
As I redesigned this, you need to separate the data from the logic. The student must be purely data. It should contain information only about the student and student. Therefore, this does not include classes, since this concept requires others, such as the subject and teacher.
The same goes for the teacher. Then I created a place to store information about the class and another place for information about the subject.
To perform such tasks, I would do the following:
gradesDatabase.getGrade(subject, student); subjectDatabase.getTeacher(subject, student);
If the object is also a data-only object.
source share