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:

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:

1 Like