Comment

Comment by marijnz0r

Regarding a unit test it looks something like this in pseudocode:

  function test_addition() {
      given_two_integers(2,3);
  
      when_summed_up();
  
      then_the_result_should_be(5);
  }
Whereas I would prefer something like

  function test_addition() {
      int a = 2;
      int b = 3;
  
      int result = new Addition(a, b);
  
      Assert.AreEqual(result.Sum(), 5);
  }
For a non-coder it might seem more intuitive to read the first example, because it only contains natural language. For a coder it seems more intuitive to read the second example, because it prevents "method hopping" (I have to go into the methods from example one to see what's actually happening inside them).
parent marijnz0r 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton