In the first section of this chapter, The SOLID principles of object-oriented design, we performed a deep dive into each of the SOLID principles and how they can be applied toward writing clean Go code:
- SRP: Group structs and functions based on their purpose and organize them into packages with clear logical boundaries.
- Open/Closed principle: Use composition and embedding of simple types to construct more complex types that still retain the same implicit interface as the types they consist of.
- LSP: Avoid unnecessary coupling by using interfaces rather than concrete types to define the contract between packages.
- ISP: Make sure your function or method signatures only depend on the behaviors they need and nothing more; use the smallest possible interface to describe function/method arguments and avoid coupling to the implementation details of concrete types.
- DIP: Use the...