• Post Reply Bookmark Topic Watch Topic
  • New Topic

Encapsulation vs Delegation  RSS feed

 
May Byrne
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the question: Explain how the concepts of encapsulation and delegation a), relate to each other and b), how they differ from each other.

I have no idea how to answer this. I know encapsulation generally means putting all related methods and objects into one class, like all the code related to managing someone's bank account. But I don't really understand what delegation is, and how it relates to encapsulation.

I appreciate any help
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Perhaps it's related to a situation where you have an object in an object (aggregation) and instead of just giving the user access to the inner object, you instead create methods that call the inner objects methods. So instead of this:


...you do this...

That is a kind of delegation that keeps encapsulation. Whether that answers the question, I don't know.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you know about delegation already?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!