Talking about your example: If you expose your object as Interface, only methods that defined under the Interface is visible and access to the other party in that way you can hide the other methods of the class from using by the other party.
here the class
BasicCalculator
has two methods,i.e
UseSinToSolveTheProblemIfStartPointIsZero
its own method and method
Solve
is an interface implementation.
void main()
{
ICalculator calculator = new BasicCalculator();
why tthis good decoupled from a specific implementation??
calculator.Solve(123);
calculator.UseSinToSolveTheProblemIfStartPointIsZero(123);
}
where as
void main()
{
var calculator = new BasicCalculator();
why tthis bad! dependency on a specific implementation ???
calculator.Solve(123);
calculator.UseSinToSolveTheProblemIfStartPointIsZero(123);
}
read more about Interfaces
@MSDN[
^]