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

Remove shared resources. #316

Closed

Conversation

dblock
Copy link
Member

@dblock dblock commented Jun 5, 2024

Description

The use of shared resource is an anti-pattern that ties together unrelated concepts. A simple example is of ChapterReader that is only needed by ChapterEvaluator. By introducing a shared resource we start treating the spec, reader and evaluator as singletons in a way that combines them in 1 place, creating unneeded interdependencies. The one thing we do need to pass around is the actual spec, which makes sense as all these classes use the spec in some way. I think the resulting code is a lot clearer (and much shorter, especially in tests where we don't need to pre-create anything).

I also cleaned up some test befores/after's.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock dblock added the skip-changelog No need to update CHANGELOG. label Jun 5, 2024
Copy link
Contributor

github-actions bot commented Jun 5, 2024

Changes Analysis

Commit SHA: d7f81ff
Comparing To SHA: 7acd0fc

API Changes

Summary

NO CHANGES

Report

The full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/9388115821/artifacts/1571919961

API Coverage

Before After Δ
Covered (%) 476 (46.62 %) 476 (46.62 %) 0 (0 %)
Uncovered (%) 545 (53.38 %) 545 (53.38 %) 0 (0 %)
Unknown 24 24 0

@nhtruong
Copy link
Collaborator

nhtruong commented Jun 5, 2024

I believe @Xtansia's #302 is already handling this.

@dblock
Copy link
Member Author

dblock commented Jun 5, 2024

I believe @Xtansia's #302 is already handling this.

Yes, but mine is much simpler because it removes unnecessary this._stuff. I can do it on top of @Xtansia's PR too.

@nhtruong
Copy link
Collaborator

nhtruong commented Jun 5, 2024

Got it. Although, I'm afraid you guys are probably stepping on each other's toe haha.

@dblock
Copy link
Member Author

dblock commented Jun 5, 2024

Got it. Although, I'm afraid you guys are probably stepping on each other's toe haha.

Yes, I should have looked. It bugged me so I went ahead and made the change. I don't mind doing the work twice or throwing it out :) Let's merge the refactor first!

@dblock
Copy link
Member Author

dblock commented Jun 6, 2024

#302 addressed this, closing

@dblock dblock closed this Jun 6, 2024
@dblock dblock deleted the remove-shared-resource branch June 7, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No need to update CHANGELOG.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants