Interfaces – the next level of abstraction

 

Interfaces resemble abstract classes in that they include abstract methods that the programmer must define in the classes that inherit from the interface. In this way, interfaces contribute to code organization because they commit the child classes to the methods that they should implement. The use of interfaces become very helpful when we work in a team of programmers and want to ensure that all the programmers write the methods that they should work on, or even in the case of a single programmer that wants to commit himself to write certain methods in the child classes.

An interface commits its child classes to abstract methods that they should implement.

How to declare and implement an interface?
We declare an interface with the interface keyword and, the class that inherits from an interface with the implements keyword. Let’s see the general case:

Comments

Popular posts from this blog

Pre-School Enrollment System using PHP and MySQL | PHP Gurukul

Global Food Ordering System Using PHP and MySQL | PHP Gurukul

Doctor Appointment Management System Using PHP and MySQL | PHP Gurukul