Interface vs. Abstract Classes

Objective: Give a brief explaination of the difference

As you can see above, we have a simple Interface. Interfaces can be seen as a set of rules that classes must follow or they will throw an error. They are used to declare only, not assign as in declare a Health property and a Damage method will be used. All declared in an interface must be implemented in the inheriting class.

Abstract Classes on the otherhand can both declare and assign but it also allows you to override inherited methods by using virtual methods. Overriding can also be additive rather than removing all earlier implemeted logic. While overriding the base method, you can add back in the original logic using the base call followed by the additive or new logic.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store