✅ Factory method
like i sincerely don’t understand this concept. could someone elaborate?
2 Replies
does it imply that we put the
new
in a different class and not in the main program?
Would that be all?yes ...i think we use factory for loose coupling and many more things
example
if you create the object directly and now you need to change your
car
to raceCar
we cant do that but with factory we can acheive that by simply changing the return new Car()
to return new raceCar()
if any wrong someone teach me too😅