Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Object-Oriented PHP Basics (Retired) Inheritance, Interfaces, and Exceptions Object Interfaces

Purpose of object interface

Why we need to use interfaces. We can define our how to ride method in each class (Bycycle, Motor Bike and Skate Board).

1 Answer

In a small project like the one in the video, you can clearly get by without one. But in larger projects, and ones on which several people are collaborating, they become much more important. As he says, they specify which methods a class must implement. If you're running a project, and you want a programmer to write some classes that implement a set of methods, you could tell the programmer which methods to include in their classes, but it's much, much better to create an interface and have the programmer make each of their classes implement the interface. One benefit is that the compiler can then tell the programmer if they have implemented the correct set of methods. There's more, but yes, they come in very handy!

Thanks Jcorum