The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Java Designers - do they have a clue?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Java Designers - do they have a clue? Posted: Aug 7, 2003 12:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Java Designers - do they have a clue?
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement
I stumbled across this article in comp.lang.smalltalk. Here's the fun part:

The extends keyword is evil; maybe not at the Charles Manson level, but bad enough that it should be shunned whenever possible. The Gang of Four Design Patterns book discusses at length replacing implementation inheritance (extends) with interface inheritance (implements).

Good designers write most of their code in terms of interfaces, not concrete base classes. This article describes why designers have such odd habits, and also introduces a few interface-based programming basics.

Interfaces versus classes I once attended a Java user group meeting where James Gosling (Java's inventor) was the featured speaker. During the memorable Q&A session, someone asked him: "If you could do Java over again, what would you change?" "I'd leave out classes," he replied. After the laughter died down, he explained that the real problem wasn't classes per se, but rather implementation inheritance (the extends relationship). Interface inheritance (the implements relationship) is preferable. You should avoid implementation inheritance whenever possible

Hmm. Yes, you should avoid deep inheritance hierarchies. But Inheritance is a tool, not a problem. Maybe the problem is that Gosling and Holub aren't bright enough to know how to use it appropriately? Or maybe the locking they see in this comes from the combination with static typing.... Hard to tell, but clues are few and far between in this article. As often happens, Dave Buck has the best response to this silly article:

The first few examples given in this article actually point to difficulties with static typing, not inheritance. Smalltalk is immune to these since it uses dynamic typing.

The "fragile base problem" (for the benefit of people who didn't read the article) is that subclasses require knowledge of how the superclasses are implemented. If the superclass changes, changes may be needed in the subclasses to compensate.

Subclassing does allow a tighter coupling between classes than normal which makes it more fragile. Good design style is to reduce subclassing by using delegation instead. Good design style is also to avoid deep class hierarchies. I wouldn't say that subclassing is evil, though. It's like saying that lots of people are killed in car crashes every year, so we should avoid cars. Often, the alternatives are worse than the problem.

Read: Java Designers - do they have a clue?

Topic: Blog : iteration 2 Previous Topic   Next Topic Topic: Tim Bacon has a blog

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use