Ganesh Jangam

Ganesh Jangam

  • 1.4k
  • 257
  • 19.6k

loose coupling of classes over interface

Jun 1 2018 3:13 PM
If i make change in IDatabase interface then it will affect, and at run while creating object of CustomerRepository we still worry about what i have to pass for constructor parameter, Does that mean still there is tight coupling for classes over interface ?
  1. class CustomerRepository  
  2. {  
  3.     private readonly IDatabase database;  
  4.   
  5.     public CustomerRepository(IDatabase database)  
  6.     {  
  7.         this.database = database;  
  8.     }  
  9.   
  10.     public void Add(string CustomerName)  
  11.     {  
  12.         database.AddRow("Customer", CustomerName);  
  13.     }  
  14. }  
  15.   
  16. interface IDatabase  
  17. {  
  18.     void AddRow(string Table, string Value);  
  19. }  
  20.   
  21. class Database : IDatabase  
  22. {  
  23.     public void AddRow(string Table, string Value)  
  24.     {  
  25.     }  
  26. }  

Answers (2)