Grokking Design Patterns for Engineers and Managers
Vote

0% completed

Factory Method Pattern

The Factory Method Pattern lets a subclass decide which concrete type to create, without the class that uses it ever naming that type.

A class often needs to make an object without knowing which one. A report generator produces a document. A parser builds a node. A notification service creates a message. The moment you write new PdfDocument() inside the report generator, that generator is welded to PDF, and adding HTML output means editing a class that already works and is already tested.

Consider a ReportGenerator

.....

.....

.....

Like the course? Get enrolled and start learning!
Prabhat Singh

Prabhat Singh

· 2 months ago

Is the source code written here a simple factory or a factory method?

Show 1 reply

Reading Progress

0%


Vote for new content