Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackSoftEng/status/838478445147471873
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited title
Link
charlag
  • 131
  • 4

How to make iOS Router design simpler? Class depends on too many classes

Source Link
charlag
  • 131
  • 4

How to make iOS Router design simpler?

I am developing an iOS app and I am moving to a VIPER-like architecture. It looks like this:

View--ViewModel--Router--ViewModel--View

The difference from the VIPER is that I have have one global Router instead of many Wireframes (it is motivated by the app functionality: almost everything can be opened from anywhere). Router holds assemblers for different screens as well as menu and navigation controller. The problem is that the app is quite big and Router is injected with too many arguments. Its constructor looks like this

struct RouterImpl: Router {

    /* ... */

    init(window: UIWindow,
         mainNavigationController: MainNavigationController,
         menuNavigationController: UISideMenuNavigationController,
         menuViewControllerFactory: MenuViewControllerFactory,
         splashScreenControllerFactory: SplashScreenFactory,
         mainViewControllerFactory: MainViewControllerFactory,
         webViewControllerFactory: WebViewControllerFactory,
         locationPickingViewControllerFactory: LocationPickingViewControllerFactory,
         cartViewControllerFactory: CartViewControllerFactory,
         productScreenAssembler: ProductScreenAssembler,
         personalAreaOrderItemsAssembler: PersonalAreaOrderItemsAssebler)

}

Where assembler is something that has view and viewModel factories and puts them together to create a single screen.

If is already way bigger than it should be but it will be even bigger if it will be finished with the same design. What can I do to make it simpler or at least to make its constructor better?