B
Brett
I'm still trying to figure out concrete reasons to use one over the other.
I understand the abstract class can have implementation in its methods and
derived classes can only inherit one abstract class. The interface has
implied abstract methods/properties and derived classes can inherit multiple
interfaces. The interface properties/methods have no implementation.
Besides definitions of the two, what are some conceptual reasons to use one
over the other? Perhaps examples of this project uses an abstract classes
vs. this one uses an interface...for these reasons.
I have one project that uses an interface. I chose the interface over an
abstract class because the derived classes all do the same thing, they just
go about doing it in slightly different ways. Their results are different
but conceptually what they do is the same thing. I don't ever see the need
for adding more methods or properties to the interface. If there is every
such a need, I can encapsulate this variability into one of the derived
classes, since it will be "one" that has such a need rather than all. That
make sense?
Thanks,
Brett
I understand the abstract class can have implementation in its methods and
derived classes can only inherit one abstract class. The interface has
implied abstract methods/properties and derived classes can inherit multiple
interfaces. The interface properties/methods have no implementation.
Besides definitions of the two, what are some conceptual reasons to use one
over the other? Perhaps examples of this project uses an abstract classes
vs. this one uses an interface...for these reasons.
I have one project that uses an interface. I chose the interface over an
abstract class because the derived classes all do the same thing, they just
go about doing it in slightly different ways. Their results are different
but conceptually what they do is the same thing. I don't ever see the need
for adding more methods or properties to the interface. If there is every
such a need, I can encapsulate this variability into one of the derived
classes, since it will be "one" that has such a need rather than all. That
make sense?
Thanks,
Brett