Skip to content

[Chore/Refactor] Simplify repository factory pattern with Django-style import_string #24353

@laipz8200

Description

@laipz8200

Description

The current repository factory implementation uses complex validation logic with interface checking and constructor signature validation. This can be simplified using Django's battle-tested import_string pattern, which is cleaner and more maintainable.

Motivation

  • Reduce complexity: Remove ~200 lines of validation code that adds little value
  • Improve performance: Add module caching to prevent redundant imports
  • Better maintainability: Simpler code is easier to understand and maintain
  • Follow proven patterns: Django's approach has been tested in production by millions of applications
  • Cleaner error handling: Simpler exception handling without multiple validation layers

The refactoring maintains full backward compatibility while significantly simplifying the codebase.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions