kuon

kuon

Naming context, again

I have read many discussions on the forum about this topic, but I still have a few “wonderment”.

Basically, my folder structure (module name) is:

lib/my_app
├── account                  MyApp.Account
│   ├── access_tokens.ex     MyApp.Account.AccessTokens
│   ├── roles.ex             MyApp.Account.Roles
│   ├── users.ex             MyApp.Account.Users
│   ├── schemas
│   │   ├── access_token.ex  MyApp.Account.AccessToken
│   │   ├── role.ex          MyApp.Account.Role
│   │   ├── session.ex       MyApp.Account.Session
│   │   ├── user.ex          MyApp.Account.User

The MyApp.Account module is mostly composed of defdelegate that forward to submodules, like MyApp.Account.Users. Code outside of account folder can only interract with the MyApp.Account module.

The files in schemas are just ecto schemas. I removed the Schema in the module name, because it’s a bit long and doesn’t bring anything.

Now, I am quite happy with this, but I have an issue with the plural names MyApp.Account.Users for example.

It is a bit hard to spot in the filesystem and when searching for the file.

I was wondering if you had suggestions for a suffix.

Like MyApp.Account.UserContext or MyApp.Account.UserManagement … (those two does not convince me).

Most Liked

christhekeele

christhekeele

I know they’re not super common in instructional material, but I find pluralized module names to be quite useful. They’re not that uncommon in Elixir projects!

Last Post!

kuon

kuon

Yeah there is a lot of coupling beween everything is Account that’s why I did split it with defdelegate but ideally, the Account.Users module should not exist. But I it does because otherwise Account becomes way too big to manage.

Where Next?

Popular in Discussions Top

mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
nunobernardes99
Hi there Elixir friends :vulcan_salute: In a recent task I was on, I needed to check in two dates which of them is the maximum and which...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement