Question Protected by gnat
4 added 265 characters in body
source | link

With two existing implementations, UFOEnemyShip & RocketEnemyShip,

To introduce every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

CLIENT CODE:

public static void main(String[] args) {
        EnemyShipFactory shipFactory = new EnemyShipFactory();
        EnemyShip theEnemy = shipFactory.makeEnemyShip("R");
        doSomething(theEnemy);
    }

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

With two existing implementations, UFOEnemyShip & RocketEnemyShip,

To introduce every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

With two existing implementations, UFOEnemyShip & RocketEnemyShip,

To introduce every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

CLIENT CODE:

public static void main(String[] args) {
        EnemyShipFactory shipFactory = new EnemyShipFactory();
        EnemyShip theEnemy = shipFactory.makeEnemyShip("R");
        doSomething(theEnemy);
    }

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

3 deleted 9 characters in body
source | link

Considering existingWith two existing implementations, UFOEnemyShip & RocketEnemyShip,

for introducingTo introduce every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

Considering existing two implementations, UFOEnemyShip & RocketEnemyShip,

for introducing every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

With two existing implementations, UFOEnemyShip & RocketEnemyShip,

To introduce every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

2 edited tags
source | link

Considering existing two implementations, UFOEnemyShip & RocketEnemyShip,

for introducing every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

Considering existing two implementations, UFOEnemyShip & RocketEnemyShip,

for introducing every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

Considering existing two implementations, UFOEnemyShip & RocketEnemyShip,

for introducing every new implementation implementing EnemyShip interface, shown below,

enter image description here

changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,

public class EnemyShipFactory {
    public EnemyShip makeEnemyShip(String shipType) {
        EnemyShip theEnemy = null;

        if(shipType.equals("U")) {
            theEnemy = new UFOEnemyShip();
        }else if (shipType.equals("R")) {
            theEnemy = new RocketEnemyShip();
        }else if (shipType.equals("B")) {
            theEnemy = new BigUFOEnemyShip();
        }

        return theEnemy;
    }
}

Is this code change in EnemyShipFactory considered a code smell? If yes, can we avoid this code smell?

1
source | link