Factory Method Pattern
Stop Using new Everywhere
At some point, every codebase reaches this stage
if (type.equals("CAR")) {
return new Car();
} else if (type.equals("BIKE")) {
return new Bike();
} else if (type.equals("TRUCK")) {
return new Truck();
}
It works...
alishakausheen.hashnode.dev3 min read