HN user

throwaway_fjmr

15 karma
Posts0
Comments23
View on HN
No posts found.

Bit of a tangent; I used to work for a fintech company that had a good few ex-Googlers. Their setup was similar to using Codespaces: cheap, locked-down Chromebooks for devs to type on, remotely accessible machines or cloud VMs in a well-separated network to host the monorepo, run builds etc.

It was an extremely miserable experience.

While I love the marketing materials of Codespaces and I want to believe in the superiority of remote development, I'm not yet convinced.

In a language as open and flexible as Clojure, this information can pass through your application without issue. Clojure programs are able to be less fragile and coupled because of this.

Or this can wreak havoc :) Nothing stops you from writing Map<Object, Object> or Map[Any, Any], right?

I think what you want is a "spy" (partial mock), not a full "mock", but yes, both are possible. You can partially mock classes, i.e., specific methods only. Syntax is almost the same, instead of mock(User.class) you write spy(User.class).

I am assuming this is easier in Ruby because you can monkey patch classes?

Mockito in Java has a nifty way of doing this with Mockito.mockStatic:

  @Test
  public void mockTime() throws InterruptedException {
    LocalDateTime fake = LocalDateTime.of(2021, 7, 2, 19, 0, 0);

    try (MockedStatic<LocalDateTime> call = Mockito.mockStatic(LocalDateTime.class)) {
      call.when(LocalDateTime::now).thenReturn(fake);

      assertThat(LocalDateTime.now()).isEqualTo(fake);
      Thread.sleep(2_000);
      assertThat(LocalDateTime.now()).isEqualTo(fake);
    }

    LocalDateTime now = LocalDateTime.now();
    assertThat(now).isAfter(fake);
    assertThat(now).isNotEqualTo(fake);
  }
Or you can pass a Clock instance and use .now(clock). That Clock then can be either a system clock or a fixed value.

Can you elaborate why? To be honest, I don't have experience with large-scale Clojure codebases, but I have my fair share working on fairly hefty Python and Perl projects, and I tend to think that the parent commenter is mostly right. What makes you think they are incorrect?

I think you are mistaken. Mocking and DI frameworks are two unrelated concepts. There is nothing in Java that forces you to use a DI framework, e.g., Spring if you want to use mocks during testing.

How do you, or how should anyone in a similar situation learn that actions have consequences?

I work for a large (not FAANG but spatially close) ecommerce company, and I’ve yet to see substantial changes or learnings after outages or mistakes.

I often find that wishy-washy post-mortems smear responsibility and deflect accountability. This doesn’t incentivize a change in behavior, and when people blindly get more trust, they often seem to simply repeat mistakes.

I think I’ve yet to master post-mortems and transforming “I told you so”s into improvements - I’d appreciate tips and ideas, thanks!

It bewilders me that people, including elected MPs, don't want to understand how electoral/representative democracies should work. The will of the People, yeah, right. It's like pub talk on a Friday. Grab a lukewarm ale and a bag of crisps, and cry about how great the empire once was. MPs should represent the best interest, not the lunatic dreams of their voters.