Discussion about this post

User's avatar
Giorgio Sironi's avatar

There is a part of pushing assumptions away that I found most challenging, which is how both the consumer and the producer interact to define a contract. For example, the consumer has opinions on the fact that a URL must be provided in the response, but the fact that the producer is located elsewhere (and reachable through HTTP) implies that a Promise needs to be used while adding all sort of possible error conditions.

Expand full comment
Adam Rose's avatar

I did something like this for a protocol I am using. The protocol has three ... well I will call them modes. The device I'm talking to supports three of them : MODE2, MODE3 and MODE5. Each of these modes uses five registers, A, B, C, D and E. I ended up with ( but did not start with ) a map for each the models which looks up the register addresses for A,B,C,D and E. The construction of this map ended up by assuming that the offsets of the addresses for A,B,C,D and E are the same for each mode. In other words only the base address of the registers changes from mode to mode, not the offsets from the base address. This assumption was hard coded into my code as I generalised from MODE2 to MODE3, and the assumption was valid as I made that transition.

The problem came with MODE5. The offsets were not the same as for MODE2 and MODE3. In fact, for MODE5, the registers are in a different order - it's not A,B,C,D,E, it's actually A,D,C,B,E. At this point, I have a problem. I know that if I write a test for MODE5, it will fail, because I have "incorrectly" generalised from the similarity between MODE2 and MODE3. But ... my company is designing this device. Frankly I just think this is a bug. I believe that my generalisation is correct and that this bug should be fixed by the people who are designing the device.

Should I :

(i) degeneralise ( ie complicate ) my code and write a working test for MODE5 ?

(ii) write a failing test for MODE5 ?

(iii) not write any test for MODE5 ?

[ Apologies for not using TDD as you can see from my question - but I think the question could be rephrased in TDD terms ]

Expand full comment
6 more comments...

No posts