Week notes numero cuatro.

Default hashcode implementation

Perfect in-depth investigation how default implementation of hashCode works in Java. I must admit that I had no clue about biased locking. You never stop learning something new about JVM.

Self encapsulation

Self encapsulation is an approach to accessing fields of objects via its own public api. I was thinking about it several times in the past and I preferred more the direct access. But this week I encountered this situation. Imagine a SomeClass with items list and a getter. There also was SomeClassChild extends SomeClass which overrided the getter method for some reason. There was also this method in SomeClass

public List<Item> getActiveItems() {
  if (items.isEmpty()) return Collections.empty();
  return items.stream().filter(Item::isActive).collect(Collectors::toList);	
}

This method was not returning expected values for instances of SomeClassChild obviously. Personally I think that the main issue is that those classes were poorly designed. BUT we make mistakes and applying self-encapsulation can safe some trouble in those situations.

Test first and test after are not equivalent

Do you write tests before or after implementation? Does it even matter? Yes it does. Both produces different results. In Symmetry breaking post Uncle Bob shows that those approaches are not indeed equivalent in yet another way.

CQRS and event sourcing

Have you ever heard of CQRS and Event sourcing? It is a shame how few applications are built using those techniques. I like any enlightening post about this topic. This is one of them: Why I still love CQRS.

Other

Very good intro to functional programming concepts
Programming sucks about how software development is actually done. TLDR: it is crazy :)