One way to avoid poor-planning is to structure your codebase around the concept of modules, each with its own responsibility.