What should I do when my context modules start getting really big

The code for my current Phoenix project is growing very quickly. The context modules (MySite.Authentication that is in lib/my_site/authentication/authentication.ex) are over 1000 lines and I can see them getting much larger. It’s starting to get more difficult to find the right function when I need to make a change.
What is the convention for this? Should I move these functions into their respective schema modules, keep them there, or make new modules?

4 Likes

Uh, that is a single module, not a context. ^.^

If a module gets big then break it up into more modules. A context is not a single module but rather, in my opinion, an entire module namespace. ^.^

5 Likes

Yep, realizing this helped me a lot too.

Also relevant https://robots.thoughtbot.com/lessons-from-using-phoenix-1-3

3 Likes