StefanSchade / TaleForge

Text Adventure Logic Engine - A plattform to create immersive games without coding
0 stars 0 forks source link

Refactor Repository access #14

Open StefanSchade opened 6 months ago

StefanSchade commented 6 months ago

Refactor Domain Service Repository Access and Dependency Management

Background

Our current architecture involves use cases in the application layer and domain services in the domain layer, both accessing repositories directly. Additionally, we utilize an AppState object for sharing services and repositories across the application. This setup has led to some redundancy and obscured the explicit dependencies between components of our application, potentially impacting maintainability and testability.

Task Description

We aim to refactor our application to clarify and streamline how repositories are accessed by domain services and how dependencies are managed across the application. The goal is to enhance separation of concerns, make dependencies explicit, and simplify our architecture where possible.

Specific Goals

  1. Evaluate Domain Service Repository Access:

    • Determine if domain services should hold references to repositories or if passing repositories as parameters from use cases would be more appropriate.
  2. Clarify Use Case and Domain Service Responsibilities:

    • Ensure use cases focus on orchestrating the application's business processes, making external calls to domain services when domain-specific logic is required.
    • Validate that domain services are focused on executing complex domain logic and not merely acting as intermediaries to repository access.
  3. Rethink AppState Usage:

    • Assess the role of AppState in dependency management. Consider alternatives that provide clearer dependency management and lifecycle control, possibly moving towards more explicit dependency injection at the point of use.
  4. Dependency Management Refactoring:

    • Implement changes based on the evaluation, aiming to make dependencies explicit and reduce redundancy. This might involve adjusting how services and repositories are instantiated and passed around in the application.

Motivation

Acceptance Criteria

This refactoring is an investment in our application's future, aiming to build a more robust, clear, and maintainable architecture that will serve us well as the application evolves.