Riccardo Cipolleschi
1 min readDec 1, 2021

--

Hi Michael, thanks for writing.

I agree with you when you say that ViewModels should not be protocol.

In this case, I'm not applying any UI pattern. This simple example is not an MVVM application. I have seen these objects used in that way in different projects, therefore I decided to go deeper into the topic and to write an article about that, in a humble attempt to prevent people from writing poor code.

That said, I'm not fully convinced about your point. The Generator in the article is not a ViewModel. It is a plain Service, which provides a function to retrieve an Int. In another context, it could fetch the next integer from a backend, for example, but we don't want its interface to change.

If I would implement the same code using MVVM, I would create a specific ViewModel for my ContentView in which we can inject the generator service dependency.

Does that make sense? I tried to keep the article as simple as possible and perhaps that is why it could have been misinterpreted. What do you think?

Thanks again for taking the time to write this comment.

Best regards,

Riccardo.

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

--

--

Riccardo Cipolleschi
Riccardo Cipolleschi

Written by Riccardo Cipolleschi

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.

Responses (1)

Write a response