• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt from Joshua Bloch's item 14  RSS feed

 
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

Where is encapsulation when I expose my private fields through accessor / mutator methods?
 
Bartender
Posts: 9444
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Joshua Bloch's item 14?
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encapsulation is brining together data and code.
THis is we are achieving by providing access to data through methods.

Encapsulation is not providing access to "how things are implemented" but to "what is to be done".

This we are achieving by providing access to accessors/mutators not to how they are performing task.

Encapsulation is avoiding classes to participate in the implementations of each others. Ans again this thing is achieved by making instance variable private and providing their access thru accessors/mutators.

Please correct me If I am wrong.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
His book Effective Java is famous. And if we mention his name along with the item number, I guess most of them could understand.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, his book is famous, and I have a copy of it. There are two editions with different numberings, and it is inconsiderate to make people go and look for a book just to understand the questions. Joe Ess is correct; you ought to have said what item 14 is about.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!