I have a vehicle class and a beautiful ship and plane to check safety, each class implements its own safetycheck. The world was good.
interface Vehicle { public void safetyCheck(); } class Ship implements Vehicle { @Override public void safetyCheck() {
But soon a hybrid called the seaplane was needed that duplicated Ship and Plane safety checks.
class SeaPlane implements Vehicle { @Override public void safetyCheck() {
What design patterns help in such specific scenarios reduce code redundancy and simplify implementation?
java design-patterns
Javadeveloper
source share