SOLID Principles in JavaScript
What SOLID principle is being applied in this refactoring example?
// Before:
class OrderProcessor {
constructor(order) {
this.order = order;
}
processOrder() {
if (this.order.type === 'physical') {
// Process physical order
} else if (this.order.type === 'digital') {
// Process digital order
}
}
}
// After:
class OrderProcessor {
constructor(orderStrategy) {
this.orderStrategy = orderStrategy;
}
processOrder() {
return this.orderStrategy.process();
}
}