Feedback on Phoenix 1.3 models


I wanted to provide some feedback on the changes in Phoenix 1.3.

First, the organization for a new umbrella app is really nice. Moving my models into a separate OTP app that the web app references is something I pieced together in 1.2 with examples posted on this forum. (

Grouping up functional areas for the models is probably a good idea. It happens naturally over the course of a larger application, and it’s a solid DDD approach, so I am for that.

Where I am having trouble is the top level files we will be maintaining, like accounts.ex and accounts_test.exs.

  1. Many functions
    These files are going to become unwieldy very quickly: 3 models is 21 functions and that’s just getting started.

  2. That are very similar
    These files have repeated functionality that is extremely similar across models. Accounts.list_users, Accounts.list_roles, Accounts.list_permissions. My thought is that I should get Accounts.User.list / get! / update / etc for free through a used module. I am trying to weigh that against being too OO, but I think there is precedence with user Genserver and providing callbacks to supply arguments the common functionality will use. A function that provides a changeset function and struct/map type to a Model module is what comes to mind.

  3. Changesets aren’t by their schemas
    I am finding the natural flow for me is to look at my schema while writing my changeset logic, and even though I can open it in another tab, it feels like it should be in the same file.

I like the 1.2 idea of testing models separate from repo side effects. I don’t want to lock into existing ways, but I think some of the new changes are going to result in more code the end developers will have to write and maintain.

I realize I am free to do as I please, and that a lot of thought went into these changes. Overall the changes are great, but maybe the above can help make things a little smoother. Thanks.


A post was merged into an existing topic: Phoenix v1.3.0-rc.0 released