T
Todd
Hello all,
While I have been programming for many years, I have decided that I
need to start thinking more like a developer than a programmer. As
such, I have been trying to improve my Java skills and OOAD skills.
One of the items I have run across in my self-education is the axiom
to "favor composition over inheritance" as it leads to more loosely
coupled designs. I am finding this difficult as I am a big user of
inheritance (I get the "is-a" relationship thing). I can see where I
could have a class that would have been a child-class have an object
of the parent class (assuming it is a concrete class) and then
delegate functionality to that object's methods. However, I don't
understand why now something that "is-a" is better off acting as if it
"has-a."
And beyond that, when is it then appropriate to inherit? It seems
that one would not want abstract classes any more because an object of
that class could be used for delegation. If one wanted to enforce
class "signatures" (help me with the terminology - I mean same method
names/signatures, etc.) one would only need interfaces. And yes, I
know that a class doesn't have to be abstract to be the root of an
inheritance hierarchy.
Thanks for your input,
Todd
While I have been programming for many years, I have decided that I
need to start thinking more like a developer than a programmer. As
such, I have been trying to improve my Java skills and OOAD skills.
One of the items I have run across in my self-education is the axiom
to "favor composition over inheritance" as it leads to more loosely
coupled designs. I am finding this difficult as I am a big user of
inheritance (I get the "is-a" relationship thing). I can see where I
could have a class that would have been a child-class have an object
of the parent class (assuming it is a concrete class) and then
delegate functionality to that object's methods. However, I don't
understand why now something that "is-a" is better off acting as if it
"has-a."
And beyond that, when is it then appropriate to inherit? It seems
that one would not want abstract classes any more because an object of
that class could be used for delegation. If one wanted to enforce
class "signatures" (help me with the terminology - I mean same method
names/signatures, etc.) one would only need interfaces. And yes, I
know that a class doesn't have to be abstract to be the root of an
inheritance hierarchy.
Thanks for your input,
Todd