Lecture overview -- Keyboard shortcut: 'u'  Previous page: Classes -- Keyboard shortcut: 'p'  Next page: Visible and Hidden aspects -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 7 : 29
Object-oriented Programming in C#
Classes and Objects
Visibility - the Iceberg Analogy

We present two very useful analogies of class visibilities: Icebergs and firewalls. On this slide, the iceberg analogy is in focus. The tip of the iceberg corresponds to the client interface. The part of the iceberg below the surface correspond to the private parts of the class.

A class can be seen as an iceberg: Only a minor part of it should be visible from the outside. The majority of the class details should be hidden.

An Iceberg. Only a minor fraction of the iceberg is visible above water. In the same way, only a small part of the details of a class should be visible from other classes.

Clients of a class C cannot directly depend on hidden parts of C.

Thus, the invisible parts in C can more easily be changed than the parts which constitute the interface of the class.

The details you cannot see, cannot be used directly in other classes. Therefore it is much easier to change the private part of the class than the interface part of the class. This is important because many classes are likely to change a lot during their lifetimes.

Read more about the iceberg analogy in the text book version of this material.