• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Inheritance as a bad practice

 
Marshal
Posts: 64690
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bertrand Meyer, writing about 25 years ago in Object‑Oriented Software Construction, which is actually about the Eiffel language, takes it for granted that inheritance is essential, and multiple inheritance to boot. Nowadays I hear people say things like, “I hardly ever use inheritance.”
Have you written anything about inheritance as a bad practice or a good practice?
 
Author
Posts: 13
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

I assume this question is for me

Inheritance gets its own section in the book. I don't label it as something inherently good or bad. It is a useful technique but one that can be easily abused in ways that cause headaches. I chose the most migraine-inducing misuses and discussed why they ought to be avoided.
 
Sheriff
Posts: 13517
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW, I really like that answer, Karl.

Do you have any advice in the book that's distinct from any of the things about inheritance that Josh Bloch goes over in his Effective Java Programming book?
 
Karl Beecher
Author
Posts: 13
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Bloch and I give any opposing advice on inheritance. If memory serves, my book discusses the problems with deep inheritance hierarchies, whereas Bloch's doesn't. (This comes only from memory however, so don't take my word as gospel. I don't want to unwittingly do a disservice to Bloch's book.) Similarly, Bloch's book contains some advice that mine doesn't.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!