Pola Factory menyediakan cara untuk membuat objek tanpa menentukan kelas pastinya — sebuah metode atau kelas yang menangani pembuatan objek, memutuskan tipe mana yang akan diinstansiasi. Pola ini memusatkan dan mengabstraksi pembuatan objek, memisahkan kode dari kelas konkret.
Apa yang dilakukan pola Factory
FACTORY → encapsulate object CREATION (instead of calling constructors directly):
→ a factory method/class decides WHICH class to instantiate and creates it
→ the caller asks the factory for an object (by type/parameter) → gets the right object
WITHOUT knowing/specifying the concrete class
→ decouples code from CONCRETE classes; centralizes creation logic
