The One-Sentence Distinction


1. Factory Method (The "Polymorphic Constructor")

The Concept: You define an interface for creating an object, but let subclasses decide which class to instantiate.

The Example (Logistics): You are building a logistics app.

Java Code:

abstract class Logistics {
    // FACTORY METHOD: The parent doesn't know what comes out.
    abstract Transport createTransport(); 

    public void planDelivery() {
        Transport t = createTransport(); // Call the factory method
        t.deliver();
    }
}

class RoadLogistics extends Logistics {
    @Override
    Transport createTransport() { return new Truck(); } // Decision made here
}

2. Abstract Factory (The "Theme" Provider)

The Concept: You provide an interface for creating families of related or dependent objects without specifying their concrete classes.

The Example (Furniture Shop): You are selling furniture. A customer selects "Victorian Style".