Configuration vs. Application Code
What you'll learn: You'll learn where to draw the line between configuration data and application logic so your config doesn't turn into a tangled mess of unmaintainable code.
The Core Problem
Configuration should be data, not logic. When you start writing complex expressions, conditionals, or algorithms in your configuration files, you've crossed a dangerous boundary. Your config becomes a second codebase—one without proper testing, debugging tools, or version control practices that apply to real application code.
Think of configuration like a restaurant menu: it lists options and choices (prices, ingredients, availability). The actual cooking—the recipes and techniques—belongs in the kitchen (your application code). If your menu starts explaining how to cook each dish with branching logic, you've made a mess.
Where to Draw the Line
Configuration should contain:
- Environment-specific values (URLs, ports, timeouts)
- Feature flags (on/off switches)
- Resource limits and thresholds
- Static mappings and lookup tables
Application code should contain:
- Business logic and algorithms
- Conditional branching based on application state
- Data transformations and validation rules
- Error handling and recovery logic
The Warning Signs
When your configuration file includes loops, complex conditionals, string manipulation, or requires its own testing suite, you've let configuration become code. This creates a maintenance nightmare: developers must now understand two languages and two execution models.
Key Takeaway: Configuration is data that drives behavior; application code implements the behavior itself. Keep configuration simple, declarative, and logic-free—if it needs unit tests, it belongs in your application code, not your config files.