CoordinatorViewModelProtocol is the idiocracy of SwiftUI

The idiocracy

If I tell people that I write MVC, people think I write massive view controller.

What’s the refactor reason?

  1. I need a centralized navigation control, which is stateful, which means it needs to be shared across some part of view hierarchy.
  2. Must be @ObservedObject, more likely an @EnvironmentObject.
  3. Design views that explicitly observes it.

House built on sand

@EnvironmentObject var coo: Coordinator
@ObservedObject var vm = ViewModel()

The art of over-generalization

Idiotic Swift

As in whatever complete opposite of idiomatic Swift.

  1. You lack of basic understanding of SwiftUI, model-view binding in particular, you work with model side of a model-view binding. View side is computed property, so every diagram is wrong.
  2. You need to buy in that dumping everything into a sink object is a good idea
  3. You fail to see putting model in reference type defeats the purpose of value type based view hierarchy
  4. You tried to re-create MVVM+C in SwiftUI for buzzwords.
  5. Somehow you decided a coordinator coupled with view on per-view basis is the best way to do this
  6. You fell into the trap of over-generalization. So your view has generic parameters complete with hard-coded factory methods.
  7. None of these shit fix any design problems of Coordinator
  8. Finally you need type-erased protocol otherwise generics won’t compile; You have to have a view model, and to pass it as generic parameter you need type-erased protocol. In other words, you have no choice, not because this is a protocol-oriented design choice.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store