--=-KsW0G4xOpuM1Wi7RJj69
Content-Type: multipart/alternative; boundary="=-W+d/wcyIfoDcraZHToqk"
--=-W+d/wcyIfoDcraZHToqk
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
What this point of having inheritance if we're just going to avoid it?
"I use it because I have it" is not a valid reason for using any
language feature of any kind. Why do we have the plethora of
$-variables in Ruby if we're just going to avoid it? Why do we have the
loop method if we generally don't use it? Why do we have any language
constructs at all beyond 16 basic assembly language statements, in fact?
Switch over to cars for a moment. A car mechanic -- a good one, anyway
-- will have a huge chest of tools. Some of those tools only get used
perhaps once or twice a year. Why does he have them? Because when
they're used, they're the single best tool for the job and other tools
are just not adequate is why.
The features of a programming languages (as well as the set of
programming languages known) are the "mechanics tools" of the
professional programmer. If you're a decent programmer, you have quite
a few of them (much like a decent mechanic has quite a few tools in his
chest). But just like a decent mechanic doesn't randomly do brake
adjustments because he happens to have a set of brake calipers, you
shouldn't be stuffing everything into inheritance trees just because the
language you use supports inheritance.
Object-oriented programming has at its core objects. Inheritance is
just one tool used for manipulating objects. Composition is another.
Your question could easily be reworded (and it's a rewording I prefer
since this is the normal problem in libraries and applications) to:
"What is the point of supporting composition and aggregation if we're
just going to avoid them?"
Branch out. Investigate other ways of constructing programs. Look
specifically into decoupling of objects if you want a more flexible and
maintainable approach to building systems.
I can use composition in any language. Ruby's an OOP. Shouldn't we use
OOP and it's patterns where they apply? Isn't that the whole point?
Look into the Gang of Four's Design Patterns book sometime. Count the
patterns that use composition and aggregation over inheritance. And
read the part that warns against overuse of inheritance....
--=20
Michael T. Richter <
[email protected]> (GoogleTalk:
(e-mail address removed))
We should sell bloat credits, the way the government sells pollution
credits. Everybody's assigned a certain amount of bloat, and if they go
over, they have to purchase bloat credits from some other group that's
been more careful. (Bent Hagemark)
--=-W+d/wcyIfoDcraZHToqk
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; CHARSET=3DUTF-8">
<META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.12.1">
</HEAD>
<BODY>
On Sat, 2007-06-10 at 08:02 +0900, Trans wrote:
<BLOCKQUOTE TYPE=3DCITE>
<PRE>
<FONT COLOR=3D"#000000">> Avoid inheritance when you don't need it -- an=
d you need it a lot less</FONT>
<FONT COLOR=3D"#000000">> than you think. Composition is usually a bette=
r approach than</FONT>
<FONT COLOR=3D"#000000">> inheritance.</FONT>
</PRE>
</BLOCKQUOTE>
<PRE>
</PRE>
<BLOCKQUOTE TYPE=3DCITE>
<PRE>
<FONT COLOR=3D"#000000">What this point of having inheritance if we're just=
going to avoid it?</FONT>
</PRE>
</BLOCKQUOTE>
<BR>
"I use it because I have it" is <B>not</B> a valid reason for usi=
ng <B>any</B> language feature of <B>any</B> kind. Why do we have the=
plethora of $-variables in Ruby if we're just going to avoid it? Why=
do we have the loop method if we generally don't use it? Why do we h=
ave <B>any</B> language constructs at all beyond 16 basic assembly language=
statements, in fact?<BR>
<BR>
Switch over to cars for a moment. A car mechanic -- a good one, anywa=
y -- will have a <B><I>huge</I></B> chest of tools. Some of those too=
ls only get used perhaps once or twice a year. Why does he have them?=
Because when they're used, they're the single best tool for the job =
and other tools are just not adequate is why.<BR>
<BR>
The features of a programming languages (as well as the set of programming =
languages known) are the "mechanics tools" of the professional pr=
ogrammer. If you're a decent programmer, you have quite a few of them=
(much like a decent mechanic has quite a few tools in his chest). Bu=
t just like a decent mechanic doesn't randomly do brake adjustments because=
he happens to have a set of brake calipers, you shouldn't be stuffing ever=
ything into inheritance trees just because the language you use supports in=
heritance.<BR>
<BR>
Object-oriented programming has at its core objects. Inheritance is j=
ust one tool used for manipulating objects. Composition is another.&n=
bsp; Your question could easily be reworded (and it's a rewording I prefer =
since this is the normal problem in libraries and applications) to: "W=
hat is the point of supporting composition and aggregation if we're just go=
ing to avoid them?"<BR>
<BR>
Branch out. Investigate other ways of constructing programs. Lo=
ok specifically into decoupling of objects if you want a more flexible and =
maintainable approach to building systems.<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE>
<PRE>
<FONT COLOR=3D"#000000">I can use composition in any language. Ruby's an OO=
P. Shouldn't we use</FONT>
<FONT COLOR=3D"#000000">OOP and it's patterns where they apply? Isn't that =
the whole point?</FONT>
</PRE>
</BLOCKQUOTE>
<BR>
Look into the Gang of Four's Design Patterns book sometime. Count the=
patterns that use composition and aggregation over inheritance. And =
read the part that warns against overuse of inheritance....<BR>
<BR>
<TABLE CELLSPACING=3D"0" CELLPADDING=3D"0" WIDTH=3D"100%">
<TR>
<TD>
-- <BR>
<B>Michael T. Richter</B> <<A HREF=3D"mailto:
[email protected]">ttmri=
(e-mail address removed)</A>> (<B>GoogleTalk:</B> (e-mail address removed))<BR>
<I>We should sell bloat credits, the way the government sells pollution cre=
dits. Everybody's assigned a certain amount of bloat, and if they go over, =
they have to purchase bloat credits from some other group that's been more =
careful. (Bent Hagemark)</I>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
--=-W+d/wcyIfoDcraZHToqk--
--=-KsW0G4xOpuM1Wi7RJj69
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
iD8DBQBHBtvVLqyWkKVQ54QRAlaXAKDP+Z14W5ksv82h8bDRoO5qtihqDwCglOlp
EzB/q9kIkRwWRnfEImSO5zU=
=XW7y
-----END PGP SIGNATURE-----
--=-KsW0G4xOpuM1Wi7RJj69--