8. Frameworks and Reuse: Interfaces & Abstract Classes

Additional Information:

To Reuse or Not to Reuse, That is the question...

Reusing code is always helpful in the long run but only because it is helpful in the long run doesn't mean you will need to use the code in the future. It is okay to create code that is not reusable just like it is okay to create reusable code. In my own personal opinion, if creating reusable code stops your whole process of creating a project or even starting it. Consider just creating non-reusable code until you learn how to create re-usable code.

Abstract Classes

The purpose of abstract classes is to provide methods and attributes to other classes. Abstract Classes must have a "Has-A" Relationship with the classes which it will provide it's properties to. An Abstract Class' methods must not have any implementations and every class which is provided with an Abstract Class' method must provide implementations for the abstract methods which it received.


Interfaces are similar to Abstract Classes but what makes them different is actually what makes them so important. Interfaces only provide methods to other classes but Interfaces have "Is-A" or "Is" relationships with other classes which makes them more adaptable with a wide range of different types of classes. Just like Abstract Classes, whatever class receives methods from Interfaces must provide implementation for that method which it receieved.


Abstract Classes provide Attributes and Methods without Implentations and Abstract Classes uses "Has-A" Relationship.
Interfaces only provide methods without Implentations and Interfaces use "Is-A" or "Is" Relationships.

Download Lesson Notes

The Object-Oriented Thought Process

Author: Matt Weisfeld