Exploring New Frontier

Interesting things happen at boundaries. Change is one of those things.
- James Grenning, Clean Code
One of the joys of reading technical books is understanding how people approach challenges and solutions. While the eighth chapter of Clean Code focuses on integrating third-party code, I derived other lessons from it.
After all, importing libraries and frameworks is a component of building functional and complex applications. Learning how to handle code written by someone else or another company is an inevitable part of being a developer. The first lesson from Grenning’s chapter is the idea that learning the code is hard; equally difficult is integrating the code into your own. He suggests writing some tests — “learning tests” — to better understand the third-party code.
Learning tests are invaluable ways to learn the API and writing tests is an easy, but also isolated, way to understand how it works. Grenning says that they’re “free” and “have a positive return on investment.” In other words, it’s not a waste of time. In the future, with new releases of the third-party package, the learning tests can provide insight as to what has changed.
I was captivated by Grenning’s anecdotal experience building a radio communications system. His team was navigating a lot of uncertainty, as the software he was building would integrate with another team’s interface. Given that the API was not designed yet, they defined their own interface (their ideal interface) and insulated certain classes from the API. This kept the code clean and consistent. Once the API was defined, an adapter was created to convert the ideal interface with the real interface.
We had a pretty good idea of where our world ended and the new world began. As we worked, we sometimes bumped up against this boundary. Though mists and clouds of ignorance obscured our view beyond the boundary, our work made us aware of what we wanted the boundary interface to be.
Grenning speaks about the “natural tension” that exists between the provider or creator of an interface and the user of it. While the provider is striving for broad applicability, the user is focused on a very specific need. While this tension can cause problems, there are ways to navigate through learning tests and creating interfaces and adapters to deal with unknown territory.