What are the differences between information hiding and encapsulation?

Encapsulation and information hiding are very closely linked concepts, though their precise definitions vary depending on who you talk to. The concept of “information hiding” was first described by Parnas (1972) who suggested that access to information should be restricted to reduce the interconnectedness of a system. He proposed that this would facilitate splitting of … Read more

Abstraction VS Information Hiding VS Encapsulation

Go to the source! Grady Booch says (in Object Oriented Analysis and Design, page 49, second edition): 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 information hiding, which is the process … Read more

Why are Python’s ‘private’ methods not actually private?

The name scrambling is used to ensure that subclasses don’t accidentally override the private methods and attributes of their superclasses. It’s not designed to prevent deliberate access from outside. For example: >>> class Foo(object): … def __init__(self): … self.__baz = 42 … def foo(self): … print self.__baz … >>> class Bar(Foo): … def __init__(self): … … Read more