Suppose I have two directories: house-1 and house-2. Each house directory needs to have files describing its windows and doors.

I am trying to understand how to name the files and directories. My current two options are:




I can see advantages and disadvantages to both of them and am trying to decide which is the better option (or if something else is better too). What should I consider when designing a filename structure such as this?

  • 1
    While not a duplicate, the advice in How would you know if you've written readable and easily maintainable code? is applicable here.
    – user22815
    Mar 12 '16 at 5:48
  • I rewrote this to make it more on topic, if this changed your intent too much feel free to edit and clarify!
    – enderland
    Mar 12 '16 at 14:07
  • 4
    Imagine you're doing a REST service with these documents as resources. You'd do something like .../house/1/windows. There is a notion of a full path name for each resource, and there probably shouldn't be redundancies within a path name (e.g. repeating the word house in a pathname).
    – Erik Eidt
    Mar 12 '16 at 17:11

Although you ask "from a developers perspective" I think there are considerations outside that narrow constraint:

  • If the files are only going to be maintained by future developers, then your first option is great. It is clear and unambiguous.
  • But if you are going to need to email files to and from business analysts or other outside parties, I would adopt your second approach. The directory structure is not going to survive the email processing, and you could end up with lots of doors.txt files in your inbox, with no idea which house they belong to.

As a developer, I would be happy with the second option so long as the directory nesting was only a couple of layers deep. I might get a tad tetchy if the file name ended up something like usa.newyorkstate.newyork.manhattan.32ndstreet.218a.suite34.doors.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.