Samuel-88

Samuel-88

How to name context module of schema name already in plural (data)?

Hello all,

I always follow the naming convention of having schema names in singular and contexts in plural.

But now I have a schema called card_data and I have no idea how to name the context since data is already in plural form.

Does anyone know what to do in this situation?

Thanks! :smiley:

Most Liked

zachallaun

zachallaun

The context doesn’t necessarily need to be the plural of the schema — in fact, contexts often contain multiple schemes. The goal of contexts is to define the “public API” that the rest of your application uses to work with those resources.

So, what kind of card data are we talking about? Playing cards? How will card data be used? Will you ever care about an individual card on its own, or will it always be a part of a deck of cards? If the latter, maybe Deck would be a useful context.

Finally: this doesn’t matter too much. Name it something, Cards for instance, and change it later when the boundaries of your application are more clearly defined. Naming things is hard, but thankfully changing names is usually not bad, especially since Elixir gives useful compiler warnings when stuff no longer exists. :slight_smile:

Where Next?

Popular in Questions Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement