All posts by erk

I love writing, computers, puns... and can sometimes be spiritual, or mindful.

The Sort

Lawyer: We intend to prove our client had no knowledge of the sort.
Prosecutor: We have definite proof the defendant had intimate knowledge of the so called Sort!
Judge: Well, we’re here to sort this out.
Journalist: Judge in Sorting Case just Sorted!

Human Rights and the Speed of Light

The value of a human life is like the speed of light.

  1. It is always constant, regardless of the circumstances. And just like the universe bends to the effects of the constant speed of light, society should bend to the effects of the constant value of a human life.
  2. Just like the speed of light is the highest value for speed, the value of a human life should be the highest value.

Header image by geralt, link, edited

Pointless Arithmetic or Incompetent Communicator?

@SuppressWarnings("PointlessArithmeticExpression")

You don’t say? Well, let me counter that with an…

@SuppressFeature("IncompetentCommunicatorErrors")

Let me explain. I’m creating a unit test where I need to do some calculations in order to create an expected value (i.e. do the same computation as the function I’m testing but differently… or usually more manually…)

So this is my test (high lighted was marked as “pointless”):

final MinMaxAverage mma = new MinMaxAverage();
		
mma.add(1d, 1d);
mma.add(2d, 2d);
mma.add(4d, 4d);
		
final double min = mma.min();
final double max = mma.max();
final double sum = mma.sum();
final double average = mma.average();
final int count = mma.count();
		
assertEquals(1d, min);
assertEquals(4d, max);
assertEquals(1d*1d + 2d*2d + 4d*4d, sum);
assertEquals((1d*1d + 2d*2d + 4d*4d) / (1d + 2d + 4d), average);
assertEquals(3, count);

Sure, this test could have used another weight, but I wanted to test with a weight of 1. And regardless… is this pointless arithmetic in a test? Or for that matter in a complex program that might actually benefit from more simple code?

Programming isn’t just coding and numbers… it’s also communicating with other programmers and yourself in a year. Some IDE simplifications aren’t necessarily simplifications at all. Sure, you can make the code look lean and nice, but you probably should think twice about that if it’s a fringe case, something you use very seldom, or in this case the attempt to make the inner workings of a function in a test more transparent.

Ah well, regardless… I fear I’m expecting the IDE to understand my thoughts and feelings… I guess our relationship is in choppy waters then? πŸ˜€