Grokking Design Patterns for Engineers and Managers
Vote

0% completed

Abstract Factory Pattern

The Abstract Factory Pattern creates families of related objects that have to match, without the code that uses them naming a single concrete class.

Some objects only work with their own kind. A Postgres connection belongs with a Postgres query builder, because Postgres quotes identifiers with double quotes and MySQL quotes them with backticks. A macOS button belongs with a macOS checkbox. A test environment needs a fake payment client, a fake mailer, and a fake clock, all fake together.

If each object is created on its own, nothing stops the wrong pairing. A PostgresConnection and a

.....

.....

.....

Like the course? Get enrolled and start learning!
Ioana T

Ioana T

· 9 days ago

for the code to match the diagram above with AbstractProduct1 (Drink) & AbstractProduct2 (Pastry), it should show that each CafeFactory house implementations offers (returns) both products (their respectice Product1 & Product2 implementations), not just one of the Product1 or Product2 implementations. They are families of products after all.

Show 1 reply

Reading Progress

0%


Vote for new content