Solutions: An Extra Team Member

Here are the solutions to the exercises in Chapter 10, An Extra Team Member: Predictive and Proactive Analyses.

Early Warnings in Legacy Code

The top hotspots at the function level, unlockAccept and addSslHostConfig, are both rather complex. One way to counter the complexity accumulation would be to introduce chunks as discussed in Turn Hotspot Methods into Brain-Friendly Chunks.

The recent changes in AbstractEndpoint.java seems to have been an extension of addSslHostConfig that gives the method the additional responsibility of replacing an existing host configuration. This also introduces some control coupling, as shown in the next code snippet:

 public​ ​void​ ​addSslHostConfig​(
  SSLHostConfig sslHostConfig,
 boolean​ replace)
 throws​ IllegalArgumentException {
 // ...snip...
 if​ (replace) { ​// <--- control coupling
  SSLHostConfig previous = sslHostConfigs.put(key, sslHostConfig);
 //...snip...

One alternative is to separate the responsibility of the replace behavior into its own method if the distinction is important.

Find the Experts

There are multiple contributors to both of those packages, but there’s also a clear main developer for each of them. In client-go, Chao Xu has contributed most of the code, and the alias deads2k has written most of the apiextensions-apiserver. If this were a corporate project, those two people would be the first to discuss the suggested extensions with.

Offboarding: What If?

Yes, the last exercise in the book was close to a trick question because Linus Torvalds turned over the maintenance of Git to Junio Hamano in 2005.[154] As a consequence, there are few remaining parts where Linus is the main developer. One such module is date.c, which models a stable problem domain. More Git-specific parts include merge-tree.c and diff-tree.c, and none of them are hotspots.

In contrast, Rich Hickey still maintains the Clojure project, and if he’d leave it would be … hmm, challenging. The figure compares the knowledge loss for Git with the simulated knowledge loss for Clojure.

images/hints/git-clojure-loss.png

Of course, knowledge loss is about more than abandoned code—for example, loss of vision, experience, and project history. Since we cannot measure those aspects, the analysis remains an approximation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.29.48