When Mihai Budiu interviewed Brian Kernighan in 2000 (http://www.cs.cmu.edu/~mihaib/kernighan-interview/index.html), Brian Kernighan was asked the following question:
He responded with the following:
Developers should be warned when they feel that code is being pushed into arbitrary places. This generally implies that the code base does not have a coherence or a sense of purpose distilled from the architecture. This is not just aesthetics or traceability; good packaging is the first step to a maintainable code base.
As we saw in Chapter 1, Building Big with Go, managing complexity is one of the main objectives of architecture. One way of doing this is encapsulation—packaging code into a higher level of abstractions, which create the firewalls that Kernighan described earlier.
This chapter delves into ways of organizing code at two levels:
- Object-orientation in Go
- Code layout of packages, dependencies, and so on
But before we go there, we need to define crisply a key aspect of module design—contracts.