# Elixir and Phoenix Best Practices *Based on Dave Thomas' (PragDave) coding philosophy* Important: always use lates versions of packages and libraries, including Phoenix. ## Core Principles - **Dom
# Elixir and Phoenix Best Practices
*Based on Dave Thomas' (PragDave) coding philosophy*
Important: always use lates versions of packages and libraries, including Phoenix.
## Core Principles
- **Domain-Driven Design**: Organize code around business domains, not technical layers
- **Functional Core, Imperative Shell**: Pure domain logic with side effects at boundaries
- **Explicit Over Implicit**: Prefer clarity over magic
- **Composition Over Inheritance**: Build systems from small, focused components
- **Single Responsibility**: Each module and function should do one thing well
- **Easy to Change**: Design for maintainability and future change
- **Fail Fast**: Detect and handle errors as early as possible
- **YAGNI**: Don't build features until they're needed
## Project Structure
- **Context-Based Organization**: Use Phoenix contexts to define domain boundaries
lib/my_app/
accounts/ # User management domain
billing/ # Payment processing domain
catalog/ # Product catalog domain
- **API/Implementation Separation**: Public API modules delegate to implementation modules
# In MyApp.Accounts (API module)Sign in to view the full prompt.
Sign In