Re your first paragraph: nicely put! That's the separation of concerns
I was referring to.

Re your second paragraph: I'd agree, except I can't detect any real
convenience for the implementation. My point is that at the time it
was defined, inheritance for the convenience of implementation was
pretty much the norm. Our ideas about how to use objects and
inheritance have evolved considerably over the past 15 years. (And the
roots of this shift go back even further, which is why Java has
interfaces rather than multiple inheritance.)

I'll point to early window systems as one of the many "object lessons"
that taught us the importance of decomposing objects. One of the
earliest examples would be the original Lisp Machine window system,
which suffered horrifically from a combinatorial explosion of classes
resulting from this. The language provided very powerful support for
multiple inheritance of implementation, but that didn't save it from
the fundamental flaw of lumping separate concerns into a single
object.

Just to be clear -- I'm not disagreeing at all. I'm just pointing out
that it was a historical mistake that we should know better than to
repeat today. The bottom-line recommendation: Ignore the fact that
Thread implements Runnable, and never subclass Thread.

And I'll take it a step further, and suggest that the actual Runnable
should seldom implement anything else, even if the thread behavior is
associated with some larger object, such as a "server object". It can
be an inner class that separates out the thread's behavior from the
overall object.

On Oct 23, 3:00 am, Kostya Vasilyev <[email protected]> wrote:
> 23.10.2010 4:04, Bob Kerns пишет:> Because you're left with two dead birds 
> instead of one?

> Having Thread implement Runnable makes using as a Runnable pretty
> obvious - and wrong. The entire reason for Thread class's existence is
> to be able to run code on a separate thread. That's clearly not the same
> as packaging code into an object, which is what Runnable does.
>
> So I'd say this is a case of inheritance for convenience of
> implementation, which is usually considered to be a bad. But it's worse
> than that, since treating Thread as a Runnable - as permitted by its
> derivation - causes Thread to completely break.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to