Let's say I have three classes: A
, B
, and C
. All of these classes are simple and they create a cohesive unit. In addition, B
depends on C
and C
depends on A
.
Most people would put these classes into one directory:
java
├── A.java
├── B.java
├── C.java
It's simple, but it's difficult to tell where the logic starts. You have no idea that B
is at the root of the dependency chain. You would have to open up the files to understand the architecture.
Instead, you could use this directory structure:
java
├── B.java
├── C
│ ├── C.java
│ ├── A
│ │ └── A.java
With this directory structure, you can easily tell that logic begins in B
and ends in A
. But it's more complicated. You might have a single file in a folder. You might have to duplicate the file name in the directory name. You also may quickly create a highly nested directory structure. But I think the advantages could outweigh the disadvantages.
I haven't seen this idea discussed anywhere, so I feel like it might be a bad idea. Would this over-complicate a project structure? Would others be able to follow along? If applying this idea to a language like Java/Python/C#, would this create too many packages/modules/namespaces and make importing too difficult? Is this a bad idea?