Example doesn’t make sense

The provided example doesn’t make sense to me. In order to create a new object using the makeF16() method you already have to have an F16 object instantiated before. Moreover in fly() you create a new F16 object within the existing F16 object context, call taxi() on it and this temporary object is never used again. Seems like a code smell to be frank. You could have just allowed subclasses to override taxi() and call it directly or use the Strategy pattern for taxying. This example doesn’t help understanding what problem the Factory Method pattern solves. Please provide a more useful example. Thanks.

1 Like