Skip to content

[ios] "Massive View Controller" (MVC) problem #173071

Description

@hellohuanlin

Use case

iOS MVC ("Massive view controller") is a widely known problem in the industry. Our FlutterViewController is getting massive with almost 3000 LOC.

Why it's a problem?

  1. hard to read & maintain. It's pretty intimidating to navigate into this massive file.
  2. testability: It's hard to write focused unit tests. Looking at FlutterViewControllerTests.mm, we had to write lots of boilerplates to setup the whole VC, which isn't necessarily related to the feature being tested.
  3. reusability: some non-UIKit components could be reused across platforms. In fact, even for UIKit-related features, we could split out the non-UI logic part (e.g. data packet logic in gesture handlers)
  4. single responsibility principle: changing one part of the FlutterVC may have unintended and unforeseen consequences.

Proposal

Consider refactoring and breaking up FlutterVC into smaller components.

An example of good practice is the keyboardManager (which handles key press events) - it has a pretty small API used by FlutterVC, and it's also much easier to unit test.

Non-goal: we probably shouldn't adopt other architectures such as MVVM. I don't see much value for our use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: contributor-productivityTeam-specific productivity, code health, technical debt.c: tech-debtTechnical debt, code quality, testing, etc.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions