Thoughts on Internal Complexity

Complexity is something that needs to be managed down and is an eternal battle. Part of the battle is to stay away from the style and cosmetical changes. Can we really get 100% of style discussions? Even removing discussions of 2-4 tabs, there will be some form of style on the discussion because every engineer has a background towards JEE, Spring, or Functional. That's a greater generalization, and there are other "design schools" over there but still quite common to find people within these 3 backgrounds. A Philosophy of Software Design is a great book that explains what complexity means. In the book, complexity is mainly described as "Obscurity," something that is not readable and has a high cognitive load to be understood. IMHO some problem spaces require you to have some background and experience on how some problems are solved; otherwise, it might look the worst they actually are. Complexity discussion often hard since lots of engineers have high EGO and have a hard time decoupling their personal self from their code. That's why it is important to have a culture of Retrospectives and continuum feedbacks. In this battle is straightforward to throw the towel and give up, but you should not give up. 

Obscurity

Obscurity happens because of a lack of continuous improvement culture. Yes, oftentimes, we need to move fast and compromise, but it is possible to keep the code base decently. IMHO a good chunk of the problem is related to the fact that code reviews to shallow and too fast. LGTM happens way too fast, and besides the fact that things can move faster, this might be actually bad in another sense. 

The issue with Github code Reviews

I personally dont like GitHub code reviews. Because code reviews in github focus on DELTAS and the DESIGN is about the WHOLE, not about what changed on the code(DELTAS). Personally, from time to time, go to the whole code repository and look at the code as a whole. IMMO is much better, and I can capture things that when I'm doing smaller reviews. Some trends and patterns can only be stoped by a more complete view with deltas do not offer. 

Obscurity Smells

See, obscurity is not subjective; you will feel it! However, we need to be TEACH to fight it because often we dont fight it. IMHO there are some criteria you can apply(besides the ones in the book), such as:
  • When you read the code, you feel something is wrong! 
  • Number of moving parts - number of classes
  • Same concern in different packages
  • Annotations, Enums, interfaces, and checked exceptions
  • Abstractions that add little or no value
  • Abstractions that are just delegators
Having more classes does not make it better; often, it is the opposite. However, if you hear these ideas the first time, they might sound wrong and even ludicrous. Since we live day and night on "Clean Code Propaganda,." Managing complexity down is a high effort but, at the same time, a high payment exercise. Fixing Obscurity means moving a bit slow, having a humility exercise in code reviews, and sometimes being right and other times being wrong(and it is fine to be wrong).  

Cheers,
Diego Pacheco

Popular posts from this blog

Java Agents

Manage Work not People

HMAC in Java