Why DRY is Overrated: A New Perspective for AI-Driven Development

For decades, "Don't Repeat Yourself" (DRY) has been one of the most widely accepted principles in software development. The idea is simple: every piece of knowledge should have a single, unambiguous representation within a system. In practice, this means extracting repeated code into functions, classes, or modules that can be reused across the codebase.
But as AI becomes an integral part of the development process, it's time to question whether DRY still holds the same weight it once did. In fact, we argue that DRY may be overrated—especially when AI is doing the coding.
The Problem with DRY and Modularity
At its core, DRY often conflicts with one of the fundamental principles of modularity: functionality should remain local unless there's a compelling reason to share it.
When we extract code to follow DRY, we're creating dependencies between modules. A function that's used in multiple places creates a shared dependency. This means:
-
Changes in one context can break another: When you modify a shared function to fix a bug or add a feature for one use case, you might inadvertently introduce errors in other parts of the system that depend on that function.
-
Increased cognitive load: Developers need to understand all the contexts where a shared function is used before making changes, which becomes increasingly difficult as the codebase grows.
-
Tight coupling: DRY can create tight coupling between otherwise independent modules, making the system more fragile and harder to maintain.
Modularity, on the other hand, emphasizes keeping functionality local and independent. Each module should be self-contained, with clear interfaces and minimal dependencies. This makes systems more robust, easier to understand, and simpler to modify.
AI Changes the Game
The traditional argument for DRY has been: "If you need to change this logic, you'll have to change it in multiple places, which is error-prone and time-consuming."
But here's the thing: AI can identify and change patterns across a codebase in seconds.
Modern AI coding assistants can:
- Search for all instances of a pattern across thousands of files
- Understand the context of each usage
- Make consistent changes across all occurrences
- Verify that changes are correct
This capability fundamentally undermines one of the primary justifications for DRY. If AI can find and update all instances of a pattern quickly and accurately, then the "maintenance burden" argument for DRY becomes much less compelling.
DRY Can Come Later
Another key insight: With AI, you don't need to apply DRY upfront.
Traditional development wisdom says: "Extract common code early to avoid duplication." But with AI, you can:
-
Build modularly first: Create independent, self-contained modules that solve specific problems. Don't worry about duplication initially.
-
Let patterns emerge: As you build, patterns will naturally emerge. Some code will be similar across modules, but that's okay.
-
Refactor with AI later: Once you have a working system, use AI to analyze the codebase, identify actual repeated patterns, and extract them into shared functions or modules.
This approach has several advantages:
- Faster initial development: You don't spend time upfront trying to predict what will be shared
- Better modularity: Each module remains independent until there's a clear need to share functionality
- Smarter refactoring: AI can identify patterns that humans might miss and suggest better abstractions
Build Modularly, Refactor Frequently
Instead of "Don't Repeat Yourself," we propose a new principle for AI-driven development: "Build Modularly and Refactor Frequently."
This principle:
- Prioritizes modularity: Keep functionality local and independent
- Embraces duplication: Allow similar code to exist in different modules if it keeps them independent
- Leverages AI for refactoring: Use AI to identify and extract patterns when they become clear
- Reduces risk: Changes to one module don't affect others until you explicitly decide to share functionality
With AI, refactoring is no longer a painful, time-consuming process. It's a quick, automated operation that can be done frequently and safely.
Real-World Implications
Consider a common scenario: You have similar validation logic in multiple modules.
Traditional DRY approach:
- Extract validation into a shared utility function
- All modules depend on this shared function
- A change to validation logic affects all modules
- Risk of breaking changes increases
Modular + AI approach:
- Keep validation logic local to each module
- Each module is independent and self-contained
- When you need to update validation, AI can update all instances consistently
- Later, if you want to share validation, AI can extract it into a shared module
The second approach gives you more flexibility and reduces risk, especially in the early stages of development.
Conclusion
DRY isn't wrong—it's just less imperative in the age of AI-driven development. The principle still has value, but it shouldn't be applied dogmatically or prematurely.
With AI as a development partner:
- Modularity takes precedence: Keep functionality local unless there's a clear benefit to sharing
- Duplication is acceptable: Similar code in different modules is fine if it maintains independence
- Refactoring is easy: AI can identify patterns and extract them when needed
- DRY can come later: Apply the principle after patterns emerge, not before
The future of software development isn't about eliminating all duplication upfront. It's about building modular, independent systems and using AI to refactor intelligently when patterns become clear.
Build modularly. Refactor frequently. Let AI handle the repetition.