posted 8 months ago
I'm studying design patterns from Head First book, and presently on chapter-4 of the book. Here the author has introduced simple factory for creation of objects using composition/ delegation. A few pages later though, Factory method is introduced, and the only difference I see between the two is the way they allow object creation. The former uses composition/delegation for creating objects using simple factories, while the latter defers the object creation using sub-classing. Though even the author has tried to describe the difference between the two in more detail, it's not clear to me. Factory method is indeed displayed as more favorable than simple factory, though the earlier relies on inheritance which is unfavorable over composition/delegation. Can anyone help clearing the differences between the two, and why the factory method is favorable? Also, please don't mix this up with Abstract factory pattern, as I haven't yet studied it.