information-hiding

Hiding classes in a jar file

和自甴很熟 提交于 2019-11-26 20:58:19
问题 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 problem than creating two projects? (Two projects: the first one contains the classes (implementation) and the other one references to the first one and contains the factory; later only the second one will be referenced) 回答1: I think you will have

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

ぃ、小莉子 提交于 2019-11-26 13:03:44
问题 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 security/privacy to some extent)! 回答1: You can store some information in image metadata. In fact that's how man digital cameras 'tag' the photos their making (camera model, date and time, GPS coords etc.). This data format is called EXIF (Exchangeable

Abstraction VS Information Hiding VS Encapsulation

烂漫一生 提交于 2019-11-26 00:26:30
问题 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 answer for these three concepts. See the separate answer below for several citations taken from there. 回答1: Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition): Abstraction and encapsulation are

Why should the “PIMPL” idiom be used? [duplicate]

断了今生、忘了曾经 提交于 2019-11-26 00:06:49
问题 This question already has an answer here: Is the pImpl idiom really used in practice? 11 answers 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 implementation details and data from the user of the library. When implementing this idiom why would you place the public methods on the pimpl class and not the

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

家住魔仙堡 提交于 2019-11-25 22:30:24
问题 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 myPublicMethod(self): ... print \'public method\' ... def __myPrivateMethod(self): ... print \'this is private!!\' ... >>> obj = MyClass() >>> obj.myPublicMethod() public method >>> obj.__myPrivateMethod() Traceback (most recent call last): File \"\", line 1, in