CIS-260 Home http://www.c-jump.com/bcc/
In this section:
Using object models to solve problems.
Using OO Design requires specific way of thinking:
Understanding difference between interface and implementation
Designing minimal interfaces
What user needs to know about functionality built into our object?
Ideally, user needs a set of operations, supported by each object.
However, the user does not care how each operation is implemented.
For example, a browser program can have
a list of bookmarks (favorites)...
...but every browser will do different things to navigate when a user clicks bookmarked item.
It is very common to use classes of objects created by somebody else.
Libraries of classes are very common.
When using somebody else's objects in our programs, we become users of the class interface.
Properly designed classes have two parts:
the interface, which contains a set of public operations provided by the class
the implementation, which typically includes everything else:
data attributes
operations that are used by the object internally.
Implementation is
what the user of an object does not see
what the user is not required to understand.
For a designer of a class, it is crucial to understand who is going to be the audience of the class users.
Implementation is hidden from the user.
A change in implementation should not require
a change of existing interface
a modification in user code.
Ability to support this requirement is a true test of the object design.
Objects are more useful when we can control the semantics of instantiation.
The goal is to provide the client with objects which are always in a good state:
|
|
|
|
|
Abstract interface means more general interface.
The opposite would be called specific interface .
Abstract interfaces tend to be more reusable.
Abstractness of an interface can be measured by the level of detail hidden by the interface:
|
|