mysticriver
1 min readMar 25, 2020

--

One question in your example

let factories = [AnyCarFactory(TeslaFactory()), AnyCarFactory(BMWFactory())]
factories.map() { $0.produce() }

If the caller already knows that the first element is TeslaFactory and second is BMWFactory why not just initialize them in the array? Why do you bother making the wrapper struct?

let factories = [TeslaFactory(), BMWFactory()]

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

mysticriver
mysticriver

Written by mysticriver

0 Followers

full-stack software engineer

No responses yet

Write a response