In spec-driven implementation, an abstraction layer is unnecessary when it adds indirection without meeting a stated requirement. Extra structure can shift attention from behavior to architecture and make code harder to review. section 3.3.2 section 4.5.4
Before keeping an abstraction, ask:
- Does the specification require it, or does it solve a demonstrated need? section 4.5.4
- Does it clarify required behavior, or add structure reviewers must reason about? section 3.3.2
- Could the feature be rewritten from its specification simply? If not, identify what unnecessary complexity remains. section 4.5.4
Listing 3.4 Abstraction-centric code
export class OrderService {
constructor(
private db: Database,
private cache: CacheService,
private validator: ValidationService
) {}
async validate(order: Order): Promise<ValidationResult> { /* ... */ }
async calculateTotals(order: Order): Promise<OrderTotals> {
const tax = subtotal * 0.10; // Invented 10% tax rate
// ...
}
async getById(id: string): Promise<Order | null> {
const cached = await this.cache.get(`order:${id}`);
// ...
}
}
The order-service example shows how caching, validation, and invented business logic can accumulate around a requested feature. section 3.3.2























