Bradley Carestia, Kate Gabel, Jason Warner | July 2024 | Angular Community Meetup

Learn Angular best practices like MVVM patterns, business logic separation, testing strategies, NX monorepo benefits & signal-based features in this community meetup talk.

Key takeaways
  • Angular components should avoid containing business logic and complex state management - these should be moved to services and pipes for better testability

  • Signal-based features in Angular require component/integration tests rather than unit tests, as they depend on dependency injection context

  • Following MVVM (Model-View-ViewModel) pattern helps enforce separation of concerns in Angular applications:

    • View: Components, HTML, DOM interaction
    • ViewModel: State management, view-specific logic
    • Model: Business logic, data access
  • NX Monorepo provides several benefits:

    • Caching for faster builds
    • Single package.json
    • Better dependency management
    • Easier version control
    • Improved project organization
  • Components should focus on:

    • Template markup
    • DOM interaction
    • Passing data between components
    • Basic view logic only
  • Business logic should live in:

    • Services
    • Pipes
    • Stores (for state management)
  • Testing recommendations:

    • Unit test services and pipes (business logic)
    • Component tests for DOM/template interaction
    • Don’t overly focus on code coverage metrics
    • Separate unit tests from component tests
  • Community participation is important:

    • Support local meetups
    • Contribute to documentation
    • Help with translations
    • Provide constructive feedback
    • Support conferences when possible
  • Keep logic pure and testable by:

    • Using pure methods in services
    • Minimizing side effects
    • Clear separation of concerns
    • Moving complex logic out of components
  • Modern Angular features like signals are changing how we architect applications, requiring adaptation of testing and architectural patterns