Package and File Organisation
By now, we have learned a few foundational principles and tools that guide and help us when working on a piece of cross-platform software. Next step is to look at how to combine and apply them to make software maintainable and the process of maintenance as smooth as possible. The ultimate goal is to make code simple and easy to work with; we also strive to simplify support of such software.
The section introduces practical advice on how to design packages and files better in a cross-platform project. This includes:
- Keep Platform-Dependent Code at Minimum
- Use Simple Branching in Trivial Cases
- No Platform-Specific Code in Main
- Use File Suffix by Default
- Use Build Tags in Mixed Cases
- An Advanced Example
- Strive for Platform-Independent Tests
- Provide Cross-Platform Tests Only When You Must.
Let's talk about each of them in more detail. And we begin with repeating one of the basic principles.