I’ve never been able to figure this out. If your language doesn’t type-check, what benefits do interfaces provide you?
I’ve never been able to figure this out. If your language doesn’t type-check, what
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Interfaces cause your program to fail earlier and more predictably when a subclass “forgets” to implement some abstract method in its parent class.
In PHP’s traditional OOP, you had to rely on something like the following to issue a run-time error:
With an interface, you get immediate feedback when one of your interface’s subclasses doesn’t implement such a method, at the time the subclass is declared rather than later during its use.