Core Principle
Only implement features when you actually need them, not when you think you might need them in the future.
Examples
Premature Abstraction (Bad)
Simple Implementation (Good)
Real-World Scenarios
E-commerce Example
Common Anti-Patterns
- Building complex configuration systems before needed
- Creating elaborate inheritance hierarchies for future extensibility
- Adding database fields for potential future features
- Implementing unneeded API endpoints
- Creating generic solutions for specific problems
Benefits
- Reduced codebase complexity
- Lower maintenance cost
- Faster development cycles
- Better focus on current requirements
- Less technical debt
Exception Cases
- Core architecture decisions
- Data structures that are expensive to change later
- Security considerations
- Regulatory compliance requirements
The above is the detailed content of YAGNI (You Arent Gonna Need It). For more information, please follow other related articles on the PHP Chinese website!