Definition

MVC-C extends MVC by adding a Coordinator to handle navigation flow, separating navigation logic from Controllers. This pattern is useful for applications with complex navigation requirements.

flowchart LR
    subgraph View
        V[View]
    end
    subgraph Controller
        C[Controller]
    end
    subgraph Model
        M[Model]
    end
    subgraph Coordinator
        CO[Coordinator]
    end
    
    V -->|user input| C
    C -->|updates| M
    C <-->|navigation| CO
    CO -->|creates| V
    M -.->|notifies| V

Flow

  1. View receives user input, notifies Controller
  2. Controller updates Model based on user input
  3. Controller delegates navigation decisions to Coordinator
  4. Coordinator manages screen transitions and creates new Views

Coordinator Benefits

  • Separation of Navigation: Navigation logic removed from Controllers
  • Reusable Controllers: Controllers can be reused in different navigation contexts
  • Centralized Routing: All navigation flows in one place
  • Deep Link Support: Coordinators handle URL routing elegantly

Use Case

Implemented in pwr-bot Discord UI components for managing complex view navigation and state transitions.

When to Use

  • Applications with complex navigation flows
  • Multi-module applications
  • Apps requiring deep linking
  • Projects where Controllers become too heavy with navigation code

Components