dimanche 29 mars 2020

Questioning about Contra-variance in TDD

I am currently learning TDD and i was wondering about the real meaning of Uncle Bob's sentence about refacto step in connection with TDD. The subject talks about Test Contra-variance in TDD and it comes from his Clean Coder Blog.

Context : Suppose I begin writing a new class. Call it X. I first write a new test class named XTest. As I add more and more unit tests to XTest I add more and more code to X and i refactor that code by extracting private methods from the original functions that are called by XTest.

Then i have to refactor the tests too. (this is where i have a misunderstanding)

About this step, Uncle Bob Said :

I look at the coupling between XTest and X and I work to minimize it. I might do this by adding constructor arguments to X or raising the abstraction level of the arguments I pass into X. I may even impose a polymorphic interface between XTest and X.

My questions are : How to identify coupling ? What does he mean by "adding constructor arguments to X or raising the abstraction level of the arguments I pass into X." and "polymorphic interface between XTest and X."

A sample code would be very welcome !! :):)

Link to the blog article in question : https://blog.cleancoder.com/uncle-bob/2017/10/03/TestContravariance.html

Thank in advance.

Aucun commentaire:

Enregistrer un commentaire