Thursday, June 25, 2009

Information Hiding

                     When writing a class, you will sometimes have to include a feature which the class needs for internal purposes only: a feature that is part of the implementation of the class, but not of its interface. Others features of the class possibly available to clients may call the feature for their own needs; but it should not be possible for a client to call it directly.In object oriented computation, there is only one basic computational mechanism: given a certain object, which is always an instance of some class,call a feature of that class on that object.

                         The mechanism which makes certain features unfit for clients’ calls is called information hiding.It is essential to the smooth evolution of software systems.In practice, it is not enough for the information hiding mechanism to support exported features and secret features.Class designers must also have the ability to export a feature selectively to a set of designated clients.They describe the effect of features on objects, independently of how the features have been implemented. 

                               It should be possible for the author of a class to specify that a feature is available to all clients, to no client, or to specified clients.An immediate consequence of this rule is that communication between classes should be strictly limited. In particular, a good object oriented language should not offer any notion of global variable; classes will exchange information exclusively through feature calls, and through the inheritance mechanism.

                               The language should make it possible to equip a class and its features with assertions, relying on tools to produce documentation out of these assertions and, optionally, monitor them at run time.Assertions have three major applications: they help produce reliable software; they provide systematic documentation; and they are a central tool for testing and debugging object-oriented software.

No comments:

Post a Comment