• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

looking at this code, why Planet class is not a Star class?

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looking at the code below, why does the explanation of the code say
"The use of inheritance in this code is not justifiable since, conceptually, a planet is-not-a star. "? but the class Planet extends class Star?
Thanks for your help.


[ September 14, 2004: Message edited by: Barry Gaunt ]
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct that in the code, planet does indeed extend star. but what they are saying is "this is bad - don't do this".

in the "real world", there is no way you could consider a planet to be a star. You would never say "the earth IS-A star" or "Jupiter IS-A star". So this code is not good OO practice. You can't justify doing this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic