The advantages of using MVVM is to reduce code inside the ViewController, and to allow for unit testing. Perhaps you’ll feel differently after going through some tutorials, or applying the concepts to some real world projects. The one thing I will say is that there is no silver bullet out there. No one pattern can solve all issues. The best thing to do is be open minded to alternative solutions, and using the solution that you are most comfortable with
So there are these relations:
V uses VM
VM configures V
And a final sample that shows how the data from ViewModel gets assigned to parameters in View. viewModel.configure(view:)
Why not simply pass the ViewModel into View and make these assignments(the configuration of the view) in view’s init method
ie convenience init(viewModel:) ?
You can do that too! In fact, that solution does a great job of slimming down the ViewController.
The strength of design patterns often lies in how abstract they can be, which means there are multiple ways you can implement them. So either way, you would still be using MVVM.
You’re correct to think we should do it in a view model or somewhere else besides the viewcontroller. In the chapter after this we use the factory pattern to switch these images, so for tutorial purposes we leave it in the viewcontroller to minimize the amount of refactoring you as the reader have to do.