Inherits will include the implementation of each method/property of the
inherited class.
Implements will only give you the same interface. You need to provide your
own implementation.
The harder question is when to use each one. Here's my opinion:
You want to inherit a class when your new class is strongly related to the
class you want to inherit. Your new class should just be a specialized
version of the base class you are inheriting. These relationships are
typical described by "Is a". For example: Secretary is an Employee. In
this case all Employees have common atrtributes such as SS number, Office
Number, ... A Secretary will only have different responsibilities and
therefore can inherit most all of the Employee class.
The reason you would want to implement a class is because the relationship
can be linked through a common interface but the implementation of this
interface will be different for every class. For example: Bears are
animals. In this example, a Bear is really not a specialized version of
Animal because each animal is very different and don't really share any
common functions. But they all need to eat, sleep, ... It's just that the
do it very differently. Since every animal is so different you can't really.
Therefore inheritance is not correct. Instead all animals will implement
the Animal interface. So, they can be looked at as both a Bear and an
Animal. If you want to know the fancy OO word for this it is called
polymorphism.
Of course you could take this further and say that a Bear is a Mammal and
mix the whole thing up. In this case you would have Bear inheriting Mammal
which implements the Animal Interface. (OOD is fun!)
"Jim" wrote:
What is the difference between using Inherits and Implements? I think I get
it, but I want to be sure.....