What is the 'best' way of coming up with context names?

I am new to Phoenix, I have read about contexts but I am confused about the ‘best’ formula to use to come up with context names. So let’s say that I am working on a blog and I would like to come up with a context for managing blog posts, what would I name the context? Someone kindly help me understand how to come up with context names in phoenix. Thanks!

There are only two hard things in Computer Science: cache invalidation and naming things.

-- Phil Karlton

There’s no easy way to come with names and this is not specific to elixir or any programming language, it is a thing that becomes easy with experience and knowing well the specific domain that you’re working on.

Thanks for your reply. In your case, if you were building a blog, what would you name the context where posts would be managed for example?

Well… YourApp.Posts?

1 Like

MyApp.Blog.Posts would be my first approach.

1 Like

You could create Account or User context for users and Post context which includes posts and comments.

Don’t get too hung up on it (i have wasted time on this) - they are easy to change in the future if you want.

3 Likes

There are only two hard things in Computer Science: cache invalidation and naming things.

— Phil Karlton

3 Likes

Admittedly, it is a challenging task. Many times, on afterthought, I caught myself disagreeing with previous name selections.

Anyway, some ideas you may consider for naming managing blog posts context might be: “Discussions”, “Conversations”, “Feedback”, etc.

But again, you may change your mind as you work on your project and the implemented functionality renders more mature.

1 Like

If the app has a different name, I would just call it Blog, otherwise and by order of preference: Blogging, Writing, Writings, Posts (if you don’t want to think too much)…

And as said already you can change that easily later.

… , and off-by-1 errors. - Martin Fowler

1 Like

Wow! I didn’t know that Phoenix has such a wonderful community!

…and finding a Rust job that’s not about cryptocurrency and decentralized finance.

1 Like

…and opening your Linkedin-account without a mailbox full of PHP and React positions.

On-topic
Context names are even harder than function names due to the strive for cohesion, yet not wanting one-module-per-function.

Tips:

  • explain your application or business (sub)domain to a friend or a rubber duck. In your explanation you will mention the context name(s). Just check all nouns.

  • don’t overthink the names. I did so once, just to replace most of them after a while as my domain knowledge grew and I saw too many function calls crossing borders*. As it’s a simple find and replace you can switch swiftly.

*GitHub - sasa1977/boundary: Manage and restrain cross-module dependencies in Elixir projects helps with this a lot.

3 Likes