In my school management system I have this partial class diagram:

enter image description here

1- In one use case student want to see his schedule of classes in week. this is what i suppose to do:

get student object from session and call method getSchedule() on that and it will give me schedule(this method calls StudentCourse, Course for getting schedule).

Is this good place to put getSchedule() method or I should place it elsewhere?


2- In another use class student's parent want to see his child class schedule, I plan to do something like this:

Because I have some use cases that parent want to see some other student information(course mark...), I create interface StudentParentInterface that have method getSchedule() and other methods and student implement StudentParentInterface, then parent has reference to StudentParentInterface not student obj directly.

parent call getSchedule() method on StudentParentInterface, is this correct?

  • Is there a reason the Parent could not make a call to Sudent.getSchedule() and such? What expansion do you see in the future that will make a StudentParentInterface useful? Dec 27, 2014 at 14:06
  • @BlueHat I dont want to Parent has access to all method of student like addHomeWorkAnswer() or something like this.
    – mohsenJsh
    Dec 27, 2014 at 14:25
  • That's fair enough, addHomeWorkAnswer() doesn't seem like something related to the student to me. Ignoring that though, you don't have to call all of the methods avalible to student from the Parent, they would be separate classes but to me they seem to have a direct one-to-many relationship rather than needing some sort of link. It looks to me like you may need to review what your classes do keeping SOLID in mind and I expect your answer will probably come out of that. I'd be reluctant to add this linking class though since they seem to have a direct relationship themselves. Dec 27, 2014 at 17:08
  • @BlueHat thnx for your attention, yes I check and addHomeWorkAnswer() does not belong to student. before all of this is it true to put getSchedule() method in Student class?
    – mohsenJsh
    Dec 27, 2014 at 17:29
  • I'll submit my response as an answer :) Dec 27, 2014 at 17:42

3 Answers 3


As said in the comments on the OP, I don't think an interfacing class class makes sense in this instance since there is a direct relationship between Students and Parents.

Think about the relationships of the concepts outside of the system. Does every student have a schedule?

By my limited knowledge I'd say it sounds like it. It also sounds like you'll want parents to possibly have something student.getGrades(). So your you'll probably have multiple parents to one student. The student wouldn't need to be aware of the parent but the parent needs to be aware of the student so each Parent object will have a Student property and would probably call getSchedule() and getGrades() etc.


At a general level, the method needs to go with the object that has responsibility for the function.

Based upon your domain, the Student has the responsibility to provide a GetSchedule() method, as the Student owns the courses that it is taking.

And while the Parent may have a requirement to be able to see the Students schedule, the responsibility to execute that method still lies with the Student and not the Parent.

So in the simple case, GetSchedule() belongs to the Student.

In the more complex case, you may have a requirement that says the Parent should be able to see the Student's schedule without involving the Student. At that point, you'll need another means to access the system so that the Parent can call the equivalent of GetSchedule(Student) and pass their Student as a parameter to the new method.

So you might create a class called Registrar, and a Parent can invoke Registrar.GetSchedule(Parent.MyStudent) in order to allow the Parent to find out the Student's schedule without involving the Student.


It's not clear to me if you're following an OO methodology that uses analysis first. That way, you first have classes that represent only the problem domain. Then you consider the same software classes, but you're allowed to deviate from that.

getSchedule() could be a method in a so-called Use-case Controller also know as Front Controller which can be seen as a special case of the Mediator pattern.


If you're having trouble finding the right place to put a method because it doesn't really go with any of the existing classes responsibilities (it violates the cohesion principle), then it's OK to create a separate class that handles that function. Craig Larman calls this a Pure Fabrication, or a class that doesn't map to the problem domain. In your case, you could call it ScheduleManager.

  • Thanks for answer, do you mean use ScheduleManager for both Student and Parent or just Parent Class, Student has his own getSchedule() method and by this do I have code duplication? I mean two times write code to show schedule.
    – mohsenJsh
    Dec 29, 2014 at 10:43
  • Don't duplicate code. ScheduleManager can have the responsibility to do that for students and parents. Dec 29, 2014 at 13:13
  • Could you please tell the reason of this decision, I want to use this decision for other method and responsibilities. cuz at least Student class is expert for showing schedule ( it has link to StudentCourse...) is this true?
    – mohsenJsh
    Dec 29, 2014 at 13:28
  • Pure Fabrication (see the link and the reference by Craig Larman) is the reason for the decision. Dec 30, 2014 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.