I have written an on-line book on how to properly organise code here
If you are a software developer, you would have heard the expression "loose coupling and high cohesion". It was first coined by the great thinker, Larry Constantine, as the guiding principle for code organisation.
Well it turns out that to this day, there is a misconception about what coupling means in this expression. Minimizing coupling is generally thought to be about minimizing dependencies. It is not. Minimizing coupling is about understanding the internals of one module without knowledge of the internals of other modules. Larry Constantine wrote "The key question is: How much of one module must be known in order to understand another module?". He uses the word key , because it is key to low complexity, low bug