Questions tagged [information-hiding]

Information hiding is the ability to prevent certain aspects of a class or software component from being accessible to its clients, using either programming language features (like private variables) or an explicit exporting policy.

Information hiding is defined as a language construct that facilitates the bundling of data with the methods (or other functions) operating on that data. Now that also happens to be the 2nd definitive notion of Encapsulation. However, since the primary definition of Encapsulation is, "a language mechanism for restricting access to some of the object's components," the two are inherently separate.

Also see

130 questions
710
votes
13 answers

Why are Python's 'private' methods not actually private?

Python gives us the ability to create 'private' methods and variables within a class by prepending double underscores to the name, like this: __myPrivateMethod(). How, then, can one explain this >>> class MyClass: ... def…
willurd
  • 10,421
  • 5
  • 26
  • 22
176
votes
22 answers

Abstraction VS Information Hiding VS Encapsulation

Can you tell me what is the difference between abstraction and information hiding in software development? I am confused. Abstraction hides detail implementation and information hiding abstracts whole details of something. Update: I found a good…
popopome
  • 11,420
  • 14
  • 40
  • 36
139
votes
11 answers

Why should the "PIMPL" idiom be used?

Backgrounder: The PIMPL Idiom (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of. This hides internal…
JeffV
  • 47,302
  • 31
  • 96
  • 120
26
votes
9 answers

Encapsulation vs Information hiding

What exactly are the differences between Encapsulation and Information Hiding? Well I know that making fields private and then making setter and getter of the fields is encapsulation. However does encapsulation mean just this? Suppose I have a class…
user1720616
  • 379
  • 1
  • 5
  • 12
25
votes
8 answers

How can you hide information inside a jpg or gif photo?

How can I write some information inside a photo file like jpg or gif without destroying the image? and of course without showing it on the photo since the whole idea is to send information in the file of photo undetected by anyone (to provide…
M. A. Kishawy
  • 4,865
  • 10
  • 43
  • 72
16
votes
4 answers

Command Pattern seems needlessly complex (what am I failing to understand?)

I've read up on the Command Pattern, and I think I'm missing something. The Command object exists to abstract away the details of the Receiver object. It seems to me that we could simply stop here, and hold references to Command objects to execute…
11
votes
5 answers

How can I implement a robust session-per-request pattern in my project, while focusing on information hiding?

I'm currently building an ASP.NET MVC project, with NHibernate as its persistance layer. For now, some functionality have been implemented, but only use local NHibernate sessions: each method that accessed the database (read or write) needs to…
Guillaume Gervais
  • 1,015
  • 2
  • 14
  • 26
10
votes
5 answers

A brilliant example of effective encapsulation through information hiding?

"Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through…
10
votes
9 answers

Is it possible to hide a password defined within C++ code

... so that browsing the disassembly won't immediately expose the password (declared as a static variable). As an example, imagine a program that has a zip file attached that it must open for assets but is not easily accessible to prying eyes. I…
SilentDirge
  • 767
  • 8
  • 17
10
votes
8 answers

Hiding classes in a jar file

Is it really impossible to hide some classes in a jar file? I wanted not to allow direct instantiation of the classes to keep it more flexible. Only the factory (or a facade) should be visible of this jar. Is there any other way than solve this…
nrainer
  • 2,383
  • 1
  • 18
  • 33
9
votes
5 answers

Difference in Information hiding and data abstraction?

Is there any difference in Data Abstraction and Information hiding? After going through all the answers in this link I am more confused. Abstraction VS Information Hiding VS Encapsulation Couldn't find any difference. Is it just that we can call…
Ankita_K
  • 643
  • 2
  • 11
  • 20
8
votes
1 answer

So now struct can have virtual function and support inheritance ? What difference with classes then ? What the true purpose of information hiding?

Possible Duplicate: What are the differences between struct and class in C++ http://www.cplusplus.com/reference/std/typeinfo/type_info/ I guess my "teacher" didn't tell me a lot about the differences between struct and classes in C++. I read in…
jokoon
  • 5,251
  • 10
  • 42
  • 78
8
votes
2 answers

JavaScript - How to hide global scope from eval'd script

I usually think of global scope as a namespace that always can be accessed from everywhere. I would like to know whether it is theoretically possible to completely hide global scope. For example, assume we have some code we would like to evaluate…
kol
  • 24,444
  • 11
  • 70
  • 104
8
votes
6 answers

Do Subclasses Inherit Private Instance Variables From Superclasses

Do subclasses inherit private fields? This question addresses the same problem but I don't quite understand how that satisfies the (seemingly) contradictory situations below. http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html Says…
Ian
  • 541
  • 3
  • 8
  • 15
7
votes
11 answers

Best way to store data between program runs in java?

What is the best way to store data between program runs in Java? I already know that you can use a text file and store the information that way, but I was wondering if there is a better way to store the information that is generated by the program…
pie154
  • 593
  • 3
  • 9
  • 28
1
2 3
8 9