Explore Library
Code Quiz

Layer Dependency Violation in MVVM

Spot the layering mistake where the domain layer leaks a dependency on the data layer.

Codetypescript
// domain/GetUserUseCase.ts
import { ApiUserRepository } from '../data/ApiUserRepository';

export class GetUserUseCase {
  private repo = new ApiUserRepository();

  execute(id: string) {
    return this.repo.fetchUser(id);
  }
}

// presentation/UserViewModel.ts
export class UserViewModel {
  private useCase = new GetUserUseCase();

  async load(id: string) {
    this.user = await this.useCase.execute(id);
  }
}

What architectural bug does GetUserUseCase contain?