This appendix contains the solutions to the exercises.
A.1 Chapter 3
A.1.1 Calculate cognitive complexity
The total cognitive complexity of the code that follows is 10:
A.2 Chapter 4
A.2.1 Refactoring a class into a record
A.3 Chapter 5
A.3.1 From traditional switch to enhanced switch
A.4 Chapter 6
A.4.1 Refactor this imperative code using streams
A.5 Chapter 7
A.5.1 Spot and refactor antipatterns
A.6 Chapter 8
A.6.1 Optimize a customer table
A.6.2 Greener autocomplete
A.6.3 Reducing the bandwidth usage of an endpoint
A.6.4 Optimizing cache memory management
A.6.5 Making a sensor summary generator greener
A.7 Chapter 9
A.7.1 Refactoring for durability