Skip to content

Commit

Permalink
Mention it is ok to use code generators
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Mar 13, 2024
1 parent 11413d9 commit b07c130
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions guides/contexts.md
Expand Up @@ -1348,6 +1348,12 @@ Great work!

## FAQ

### When to use code generators?

In this chapter, we have used code generators for schemas, contexts, controllers, and more. If you are happy to move forward with Phoenix defaults, feel free to rely on generators to scaffold large parts of your application. When using Phoenix generators, the main question you need to answer is: does this new functionality (with its schema, table, and fields) belong to one of the existing contexts or a new one?

This way, Phoenix generators guide you to use contexts as namespaces, allowing you to group related functionality, instead of having several dozens of schemas laying around without any structure. And remember: if you're stuck when trying to come up with a context name when the grouped functionality in your system isn't yet clear, you can simply use the plural form of the resource you're creating.

### How do I structure code inside contexts?

You may wonder how to organize the code inside contexts. For example, should you define a module for changesets (such as ProductChangesets) and another module for queries (such as ProductQueries)?
Expand Down

0 comments on commit b07c130

Please sign in to comment.