• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

BJO - information hiding v/s encapsulation

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jacquie,

Could you or anybody please tell me is there any diffrence between information hiding and encapsulation?

I think both are same.

Thanks.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The two are (kind of) synonymous. Though of course an Object can contain methods as well as data, so "information hiding" is a poor choice of terminology to use. Where did you come across it?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Information hiding is one way we implement encapsulation.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fair enough. Not a term I'd heard before - but I did come across this after a quick google.
 
author
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the term "information hiding" in an OOP context to refer to the fact that many details of a class are "hidden", namely:

- private attributes
- private methods
- and, even for public methods, the implement of HOW the method works is, in a sense, private

Think of the term "information hiding" as meaning "hiding details about the inner workings of a class (of objects)".

I use the term "encapsulation" in an OOP context to refer to the fact that everything an object needs in order to fulfill its mission in an application is, in theory, encapsulated within the object, as either a piece of data (attribute), reference to another object that it can turn to for collaborative help (attribute), or as a method. However, we also know that by linking together objects at run time, we can empower them to do much more than any one object can do on its own, just like the employees in a corporation, or the cells in your body, or ants in an anthill, can accomplish more collectively than on their own.

I hope this helps!

Jacquie
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
Fair enough. Not a term I'd heard before - but I did come across this after a quick google.



Seems like there actually is no generally agreed upon definition of both terms... :roll:
 
Jacquie Barker
author
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:


Seems like there actually is no generally agreed upon definition of both terms... :roll:



As is true of so much terminology!!!

Yet another way that I've talked about encapsulation is as a benefit of information hiding: namely, if we change a private detail -- data structure or internal workings of a method -- of a class, then the changes are "encapsulated"/bounded/contained within the class itself -- i.e., there are no "ripple effects" on the application as a whole.

Looking up encapsulation on
dictionary.com, I found:

1. The condition of being enclosed (as in a capsule);

2. The ability to provide users with a well-defined interface
to a set of functions in a way which hides their internal
workings. In object-oriented programming, the technique of
keeping together data structures and the methods (procedures)
which act on them.


Best,

J.
[ July 15, 2005: Message edited by: Jacquie Barker ]
 
Skool. Stay in. Smartness. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic