Responsibilities of Objects

Here’s a quick refactoring tip.

Try to turn something like this…


public class Facility{
private boolean isGasBaseProduct(MeasurementPoint measurementPoint) {
return measurementPoint.getProduct().isGas()
|| measurementPoint.getProduct().isGasLiquid()
|| measurementPoint.getProduct().isGasByProduct();
}
}

…into this:


public class MeasurementPoint{
private boolean isGasBaseProduct() {
return getProduct().isGas()
|| getProduct().isGasLiquid()
|| getProduct().isGasByProduct();
}
}