Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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