ANONYMOUS wrote:
> When we use inheritance (extends), we create a dependency on the parent class, correct? Does using an interface instead of an abstract base class make our code more flexible?
Dependency can have various meanings, and I am not sure how you are using it here. The same goes for the concept of flexibility.
As a sweeping generalization, I would say that interfaces are "more flexible" than inheritance. Interfaces have no implementation details to inherit, and so it is impossible to depend on those implementation details and end up coupled with them. However, inheriting implementation from another class is sometimes explicitly desired to enable code reuse. It is better to have a single (private) implementation that every class that needs it reuses than to have every class reinvent the wheel. One reused implementation is more flexible to change than many reimplementations of the same.
If you want to read ahead, we will be covering interfaces and these sorts of OOP design concepts in future lectures. You may particularly want to look into the SOLID design principles, which are a set of conventions to help write better structured and more maintainable OOP code.