Saturday, July 7, 2012

When a code base uses a directory structure deeper than one level

6 comments:

kbob said...

How do you feel about a program that uses more than one level of nested scopes? (-:

Joe said...

Hmm, could you convince me? I still have trouble with it, since it seems like an arbitrary constraint.

Instead, I think projects at the point of collapsing to another level should be split into multiple projects.

But you don't always have the convenience of doing so. And I'd much rather filter through a hierarchy than dozens of flat files for what I'm looking for. Match the file structure with the namespace.

Could you elaborate and possibly enlighten me?

Aaron said...

Joe, when I'm looking for something, I grep. Or use and IDE with a namespace / class / function browser. Or I highlight a symbol and press the "goto symbol definition" hotkey.

I guess what I'm saying is that I already have enough organizational structure in the source code -- why in files too?

Joe said...

Aaron, it's to cover more fronts.

I do like using those tools, but I think organizing your files is important as well. I personally like mirroring namespaces with directories. That way, when browsing on GitHub or Bitbucket, you can still find things quickly. Mentally, search effort is proportional file count. Perhaps with a multiplier, since it can easily get overwhelming.

fuzzy said...

I'm trying to imagine a million line code base squished down to two layers deep. It's not a pretty thought.

Arcane Sentiment said...

@fuzzy: I've worked on such a codebase. Parts were two levels deep and parts had Java-style hierarchy; the flat parts were easier to navigate. A million lines is only a thousand 1000-line files; that's e.g. 25 directories with 40 files each, which isn't enough to pose a navigation problem. The contents of those files, on the other hand...