Providing a common minimal public interface
- What is a common minimal public interface?
- Articles about minimal public interfaces
When using a class to produce a new type,
the class should provide:
if appropriate, a method called
a constructor that initializes the object from a parameter of type
set methods (if appropriate);
some means for cloning an object.
Some of these
are needed if objects are to be stored in a collection
(e.g., a list).
We may be uncertain as to what
will want to do
with objects ...
... Best not
to change the class later
or produce a subclass later.
... Instead, we should provide the required features at the outset.
Perhaps, a class is poorly constructed unless it has all of these.
minimal public interface
is taken from
Arthur Riel's book
'Object-Oriented Design Heuristics'
‘If the classes that a developer designs and implements
are to be reused by other developers in other applications,
it is often useful to provide a common minimal public interface.
This minimal public interface consists of functionality
that can be reasonably expected from each and every class.’
'The canonical object idiom'
by Bill Venners
also discusses this subject.