Why don't you use interface to access ActionScheduler

As far as I know the interfaces in OOP are the safest way to exchange information between different classes. So, I understand that one is used to call the Cancel method from the scheduler class however, I don’t understand why this same interface is not used to call the StartAction method from the scheduler class.

Is it inefficient and unnecessary? Shouldn’t it be done because it would cause a problem? I have not understood the concept of interface well? Or is it simply not done to simplify things in the course?

I know it is a question that may exceed the purpose of the course but I would appreciate someone answering it to me.

Thank you very much in advance.

I believe this was answered on the Udemy Q&A relating to this lecture :slight_smile:

Sam — InstructorAnswer
a year ago

2

In theory you are right that it’s better to depend upon interfaces than concrete classes. In practice, this would mean creating an interface for every class and multiple interface for some. This obviously takes time so it needs to be justifiable. Reasons to do this include being able to unit test more easily and wanting to decouple two classes. In this case, we already had a dependency from the Mover and Fighter to the ActionScheduler (or its interface) so we didn’t really need to decouple any more.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms