DRY
Duplicate knowledge is more dangerous than duplicate syntax because it creates multiple sources of truth.
Not every design principle needs a full pattern catalog behind it. DRY, KISS, YAGNI, and the Law of Demeter are smaller heuristics, but they show up constantly in design reviews. Together they help teams avoid duplication, unnecessary complexity, premature abstraction, and brittle object navigation.
In e-commerce systems under delivery pressure, duplication and overengineering often appear side by side. One service copies validation logic in three places, while another introduces abstractions for features that may never exist. These heuristics help keep the model simpler and more resilient.
DRY is most useful when it removes duplicate business knowledge, not when it aggressively extracts every repeated line. KISS reminds you that understandable designs often outperform clever ones. YAGNI protects the system from speculative complexity. The Law of Demeter helps limit fragile navigation through object graphs.
These heuristics often work together. A team that ignores YAGNI may create abstractions too early. A team that ignores Demeter may build brittle chains of calls. A team that over-applies DRY may produce abstractions so generic that readability collapses.
Used well, these principles keep OOAD grounded in actual needs.
Duplicate knowledge is more dangerous than duplicate syntax because it creates multiple sources of truth.
Prefer the simplest design that meets the current need, and do not build speculative structure without evidence.
Objects should collaborate through nearby, meaningful relationships instead of reaching deep into internal structure.
package org.javaomnibus.ecommerce.principles;
public final class NotificationComposer {
public String compose(Order order) {
return "Order " + order.id() + " will be delivered to " + order.deliveryCity();
}
}
final class Order {
private final Shipment shipment;
private final String id;
Order(String id, Shipment shipment) {
this.id = id;
this.shipment = shipment;
}
String id() {
return id;
}
String deliveryCity() {
return shipment.deliveryCity();
}
}
record Shipment(String deliveryCity) {}
These heuristics can conflict. Removing duplication too early may hurt readability. Avoiding all abstraction may create repeated rules. The goal is disciplined simplicity, not rigid slogans.