• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in encapsulation.  RSS feed

 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ..


The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.

Can you please explain me with an example ?.

Thanks
Praveen


 
Kevin Workman
Ranch Hand
Posts: 151
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java library is perhaps the best example ... Take for instance the java.util.HashMap class

Its been around for quite a long time, but the interface the it has provided to its users has remained stable.
However it has under gone a lot of internal changes to make it more efficient, faster...

By encapsulating away these details of how it works internally, it has shielded the user from any problems.

Kind of simplified but I hope it gets the point across ....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!