Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question on object reusability

 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between object reuse using inheritance versus object reuse using composition. Which of these techniques breaks the encapsulation of the extended object.


Thank you
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is either an interview question, or a school essay question. We won't answer it for you, but we could help you put an answer together. First tell us what "inheritance" and "composition" are.
 
Vallabhaneni Suresh Kumar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Holding the reference of the other class within some other class is known as composition.
Acquiring the properties of a base class into the child class is known as inheritance

Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic