Link to home
Start Free TrialLog in
Avatar of N_Sri
N_Sri

asked on

How interface provides decoupling to the client

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interface
{
  interface Interfface
  {

     void ADD();
     void SUB();

  }

  //Service Provider
  class ServiceProvider : Interfface
  {
    public void ADD()
    {
      Console.WriteLine(" I am ADD");
    }


    public void SUB()
    {
      Console.WriteLine(" I am Sub");
    }


  }


  class Program
  {
    // Client
    static void Main(string[] args)
    {

      Interfface Reff = new ServiceProvider();
      Reff.ADD();
      Reff.SUB();
     

      
    }
  }
}

Open in new window



Here the client is aware of Service Provider and Client he is creating reference to service provider.

There client is aware of service provider.
"   I have studied client need not to now the implementation part of service provider. "

But here client knows about service provider and client is also creating reference of it.

So I think client can get the logic of service provider by using Reflection concepts  in .NET.

Can you please help me  understanding this case.



ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N_Sri
N_Sri

ASKER

Can you give code example
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N_Sri

ASKER

Thankyou