0

I have the following scenario:

enter image description here

As you can see, I have two classes that are Lecturers and Students. The class Teacher Assistants are a mix between Lectures and Students, that is because they can enrolled into courses, but they can also lecture some basic topics (without being considered Lecturers). I came with the idea to model this situation using Interfaces because I will program in in Java. Is this modelling correct?

enter image description here

So that the TA class will implement the Interface Teaches, which contains an array of the courses assigned to this student to teach.

But if I model in that way I realize that I am loosing the class Lecturers at all. How I can model this situation of multiple inheritance, but not loosing the class Lecturers? I mean if I program Lecturers as an interface it would not have any methods that I would need further, for example, calculus of its wage benefits and so on. Any recommendation?

3 Answers 3

3

You can make Lecturer into an interface, then have both TeachingAssistant and Professor implement it. TeachingAssistant can extend Student, because from a logical point of view, teaching assistants are students.

Sign up to request clarification or add additional context in comments.

2 Comments

But Logically student needn't have any properties from lecturer. Better would be to have a different interface for students. TA would implement both students and teachers interface.
That's why Lecturer is just an interface.
1

One option is to have Teacher and Teachable interfaces and then have Lecturer implement Teacher (for want of a word like Teacherable!), Student implement Teachable and TA implement both Teacher and Teachable.

Lecturer, Student and TA could all extend Faculty_Staff.

Comments

1

tbodt's approach, in my opinion, is generally sound. You just have to ask: if some client code needs a Lecturer, would an instance of a TA suffice? If there's an issue with that, you can choose to design it with composition, abstracting the ability to teach into a separate class of its own, something like TeachingJob (I can't think of a better name). This way the only thing that actual Professors and TeachingAssistants share is that they have similar teaching jobs; they do not belong to the same "class" (interface actually).

Hybrid approach would be to involve TeachingJob with the Lecturer interface, e.g. Lecturer would have a assign(TeachingJob assignment) method.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.