docs: define patterns vs conventions in README
Patterns are prescriptive — follow them. Conventions are descriptive — study for ideas. Clarifies repo purpose, directory structure, and how to use patterns during development and review.
This commit is contained in:
@@ -1,15 +1,31 @@
|
||||
# Elixir Patterns
|
||||
|
||||
Idiomatic Elixir patterns extracted from the [Elixir source code](https://github.com/elixir-lang/elixir) with verified file:line citations.
|
||||
**Prescriptive.** Follow these when writing Elixir code.
|
||||
|
||||
A pattern is a reusable solution to a recurring problem. Each one has:
|
||||
- **When to use** — the problem it solves
|
||||
- **When NOT to use** — where it causes harm
|
||||
- **Why** — the reasoning, not just the rule
|
||||
- **Source citations** — verified file:line from real codebases
|
||||
|
||||
These are derived from what mature Elixir codebases *actually do*, not opinions or blog posts.
|
||||
|
||||
## Structure
|
||||
|
||||
- `patterns/` — Core patterns (GenServer, error handling, data transforms, processes, testing, docs, typespecs, macros, behaviours, modules)
|
||||
- `smells/` — Anti-patterns and common mistakes the Elixir team avoids
|
||||
- `changelog/` — Daily digest of merged Elixir PRs with discussion summaries
|
||||
- `patterns/` — what to do (behaviours, GenServer, error handling, testing, typespecs, etc.)
|
||||
- `smells/` — what NOT to do (anti-patterns, common mistakes)
|
||||
- `sources/` — reference material from specific projects (Oban, elixir-lang). Study for ideas, don't copy blindly.
|
||||
|
||||
## Philosophy
|
||||
## How to use
|
||||
|
||||
These rules are derived from what the Elixir source code *actually does*, not opinions or blog posts. Every pattern cites specific files and line numbers.
|
||||
1. **Before writing code:** check if a relevant pattern exists
|
||||
2. **During review:** verify code follows documented patterns
|
||||
3. **If code deviates:** either fix it or document why the deviation is justified
|
||||
|
||||
When unsure how to do something in Elixir, look at how Elixir core does it. This is how we define what "idiomatic" actually means.
|
||||
## Patterns vs Conventions
|
||||
|
||||
**Pattern** = prescriptive. "When you face X, do Y." Language-scoped. Follow these.
|
||||
|
||||
**Convention** = descriptive. "Project Z does it this way." Context-specific. Study for ideas — applying another project's conventions to yours without understanding their constraints causes harm.
|
||||
|
||||
The `sources/` directory is convention material absorbed from thin repos. The `patterns/` directory is what you actually follow.
|
||||
|
||||
Reference in New Issue
Block a user