dimanche 31 mars 2019

How do interfaces break dependancies of classes?

I am reading Clean Architecture - Bob Martin. He talks about breaking dependencies with an interface. For example. Class B uses class A. Thus, class B is dependant on class A(B--->A). We can add an interface and have B dependant on the interface and also have A dependant on the interface(A--->I<----B).

What I am not understanding is that if class A has private member variables that are used in the functions that B needs. Wouldn't I have to rewrite the same code in B that A has? Also, wouldn't this just be duplicate code?

Aucun commentaire:

Enregistrer un commentaire