Factory Pattern is a creational design pattern used to create objects without exposing the creation logic to the client.

When object creation logic is scattered everywhere using new, the code becomes hard to maintain and extend.
لما نستخدم new في أماكن كتير، الكود بيبقى معقّد، صعب التعديل، وصعب التوسّع.
A coffee shop prepares different types of coffee.
The customer does not know how the coffee is made.
📌 The coffee shop = Factory
if (type =="Espresso")
{
coffee =new Espresso();
}
elseif (type =="Latte")
{
coffee =new Latte();
}
The client handles object creation.
العميل هو اللي مسؤول عن إنشاء الكائنات، وده غلط.