This appendix contains the solutions to the exercises.
A.1 Solutions to Chapter 3 Exercises
A.1.1 Calculate cognitive complexity
The total cognitive complexity of the code below is 10.
A.2 Solutions to Chapter 4 Exercises
A.2.1 Refactoring a class into a record
A.3 Solutions to Chapter 5 Exercises
A.3.1 From traditional switch to enhanced switch
A.4 Solutions to Chapter 6 Exercises
A.4.1 Refactor this imperative code using streams
A.5 Solutions to Chapter 7 Exercises
A.5.1 Spot and refactor antipatterns
A.6 Solutions to Chapter 8 Exercises
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 Solutions to Chapter 9 Exercises
A.7.1 Refactoring for durability