20.7 C
New York
Wednesday, August 20, 2025

Your code is extra strongly coupled than you suppose



The important thing query: Would altering thread scheduling, community latency, or a timeout alter correctness? Then you may have connascence of timing.

Connascence of worth

Connascence of worth happens when a number of values should be correctly coordinated between modules. For example, think about you may have a unit check that appears like this:


[Test]
process TestCheckoutValue {
  PriceScanner = new TPriceScanner();
  PriceScanner.Scan('Frosted Sugar Bombs');
  Assert.Equals(50, PriceScanner.CurrentBalance);
}

So we’ve written the check. Now, within the spirit of Take a look at Pushed Growth, I’ll make the check go as simply and easily as potential.


void PriceScanner.Scan(aItem: string) {
  CurrentBalance = 50;
}

We now have tight coupling between TPriceScanner and our check. We clearly have connascence of identify, as a result of each lessons depend on the identify CurrentBalance. However that’s comparatively low-level connascence, and completely acceptable. We now have connascence of sort, as a result of each should agree on the sort TPriceScanner, however once more, that’s benign. And now we have connascence of which means, as a result of each routines have a hard-coded dependency on the quantity 50. That ought to be refactored.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles