Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Class metadata models #48

Merged
merged 10 commits into from
Oct 29, 2024
Merged

Add Class metadata models #48

merged 10 commits into from
Oct 29, 2024

Conversation

notaphplover
Copy link
Member

@notaphplover notaphplover commented Oct 27, 2024

Added

  • Added ClassMetadata models.
  • Added getClassMetadata.

Motivation

In order to migrate inversify, several responsibilities are being moved from inversify to @inversifyjs/core. The first one is metadata management.

Currently, inversify has this responsibility distributed among several modules, making hard figuring out what's expected to be stored as metadata:

  • It's currently challenging to know what's the expected metadata associated to a type. inversify metadata internal data structures don't represent some edge cases (like the handling of lazy service identifiers).

  • Several checks as enforcing no duplicated tags can be simplified with the right data structures.

  • Code can be decoupled from reflect-metadata, making it more maintainable.

  • This decoupling would unlock the implementation of better metadata representations. This can result in reducing the operations and the amount of objects involved in the process of planning the instantiation of a service, something that would result in the simplification of the source code and boosting the performance of the library.

  • ClassMetadata is proposed as a data structure that represents the metadata associated to a certain type. This data structure handles in an efficient way most of the operations involved in the planning process.

Testability

Once this approach is discussed and validated, several tests must be included:

  1. Unit tests should validate all the code flows with a decent mutation testing score.
  2. E2E tests should enforce getClassMetadata is consistent with inversify's MetadataReader and Target.

@notaphplover notaphplover self-assigned this Oct 27, 2024
@notaphplover
Copy link
Member Author

Hey @rsaz , I've been analyzing the way inversify handles metadata in order to delegate that responsibility in this package. I've drafted this proposal, what do you think about it?

@notaphplover notaphplover marked this pull request as ready for review October 29, 2024 19:16
@notaphplover notaphplover changed the title [POC] Class metadata models Add Class metadata models Oct 29, 2024
@notaphplover notaphplover merged commit c057878 into main Oct 29, 2024
3 checks passed
@notaphplover notaphplover deleted the poc/class-metadata-models branch October 29, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants