constitutes what is called the user interface
of the class of the type in question.
Here, in our class Rectangle, for the new type Rectangle
we have defined as user interface
the calculation of the surface, the rest constituting the
implementation details that are inaccessible to the user of the type Rectangle.
Here we have the key that gives
the program more robustness if they changes are made to them.
Usually, when you change car
even if the motor technology is different,
the interface is more or less the same.
You will still be able to drive,
even if the internal details of implementation of your car
have changed.
So you only see your car as an abstract object.
You only see that
which you use to drive,
namely, the steering wheel, the throttle, the break peddle.
In summary, encapsulation,
is consolidating into one same entity
the data and functions that characterize it.
And it is also the fact of concealing the implementation details,
and defining a user interface of the class
with the encapsulation mechanism,
that will result in abstraction,
and an abstract perspective of the object.
We will only what the object has to offer in its user interface,
and what manipulations are possible.
So concretely the class programmer will decide
on the existence of a new type,
and will have to address the implementation details.
He will have to decide what is visible to the outside world,
what can and cannot be used.
The class user, on his side, uses
the new data type.
But he will have to use it through the interface.
That is to say, its visible methods
in most cases.