Phoenix v1.3.0-rc.0 released

Just wanted to drop my 2 cents for the directory structure.

I think, this depends on the perspective from which you’re discovering the project.

If you’re browsing through the directories (eg. in your editor’s navigation panel), then I guest it’s quite easy to understand that the lib/accounts/accounts.ex is the main entry point (because the file is named the same way as the directory).

On the other hand, if your starting point of exploration is the source code, eg. exception message like

** (UndefinedFunctionError) function Accounts.create_transaction/0 is undefined or private.

you might start looking for file lib/accounts.ex, which doesn’t exist.

I guess, for shallow directory structure (like the one presented here) this might not be too much of a problem, but is this something that will scale well if it gets more nested? (PS. I also accept, that this might be a smell that should make one think about refactoring, thou).

Bottom line is - both Accounts.Foo and Accounts modules are defined in lib/accounts/ - in this context, module name builds quite valuable expectation, which unmet, might cause confusion.

I think, convention, is something that will help you in longer term. Not only for people maintaining projects, but also newcomers starting their journey with Elixir/Phoenix.

3 Likes