It is dirty code ? inherit class without adding any new behavior [closed]
I am still a newbie on my professional journey as a developer. I read code from the existing project and see there is some class that extends to another class but doesn't add any new behavior. So the project is about claiming coupons, and there is an endpoint for canceling claiming coupons. The code for this process exists in every merchant controller, let's say I have two merchants, Bus and Train.
cancel(@RequestBody BusCancelRequest) { ... } // this in BusController.java
cancel(@RequestBody TrainCancelRequest) { ... } // this in TrainController.java
each of BusCancelRequest.java and TrainCancelRequest.java extends class MerchantCancelRequest.java.
public class BusCancelRequest extends MerchantCancelRequest {
}
public class TrainCancelRequest extends MerchantCancelRequest {
}
public class MerchantCancelRequest {
private String orderCode;
public String getOrderCode() {
return this.orderCode;
}
}
as you can see, BusCancelRequest and TrainCancelRequest don't add any new behavior. Is this dirty code ?
Comments
Post a Comment