Something I've been wondering about recently is how to organize types in directories/namespaces w.r.t. their dependencies.

One method I've seen, which I believe is the recommendation for both Haskell and .NET (though I can't find the references for this at the moment), is:


My natural inclination, however, is to do the opposite:



  • Is my inclination bass-ackwards?
  • Are there any major benefits/pitfalls of one over the other?
  • Is it just something that depends on the application, e.g. whether you're building a library vs doing normal coding?
  • This can't work, most types depend on multiple other types, and have dependencies of their own. They can't be in multiple folders though as well as their own folder. I have never heard of anything like this. Things should be organized based on what they do and are used for. – Jimmy Hoffa Jun 26 '13 at 16:33
  • @JimmyHoffa I realize that types will depend on more types that are in other directories/libraries, but I was thinking of types that are directly related to the root types as shown above. Perhaps my whole notion is ill-conceived. – paul Jun 26 '13 at 17:22

I also feel an urge to put lower level types in lower level folders. In practice, however, you may need to put lower level types in higher level folders. By .net convention, more specialized types tend to be found in more deeply nested namespaces, and the namespace hierarchy is reflected in the directory hierarchy. More general types go into higher level namespaces. The rationale behind this convention: to shield the API user from excessive details, until those details are needed. The API user begins exploration at the higher level namespace.

  • this post is rather hard to read (wall of text). Would you mind editing it into a better shape? – gnat Jun 27 '13 at 7:21
  • Interesting point about the flow of discovering code, I hadn't thought along those lines before. – paul Jun 27 '13 at 12:27
  • @gnat: 6 sentences is excessive? Perhaps it is a generational difference. – Frank Hileman Jun 28 '13 at 18:28
  • 1
    @gnat: I tried to improve the quality. I resisted bullet points. – Frank Hileman Jun 29 '13 at 16:57

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.