News for hackers. Stuff that matters.
Re:There’s No Such Thing as Clean Code by SideburnsOfDoom on Friday January 28, 2022 @04:56AM (#30112663)

    assertEqual(c.re(), 4);
    assertEqual(c.im(), 7);
This is "logically" one assert, on two lines. So I would welcome it

In cases like this I find myself extracting a helper assert method if it gets used 3 or more times.

e.g.

  assertEqualComplex(c, 4, 7); 
which contains

    assertEqual(c.re(), x);
    assertEqual(c.im(), y);
Which makes that a bit clearer. This is not the best example but you can get the idea. I might have 5-10 lines in an assertTransactionSuceeded(txn) method.

There are no comments on this comment yet.