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

Application refactor #591

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

toasted-nutbread
Copy link

I mentioned that I was wanting to do this in a comment somewhere, but this change makes the initialization process a bit less spaghetti. yomitan is no longer a global, and instead an Application instance is passed around to the components that need it.

@toasted-nutbread toasted-nutbread requested a review from a team as a code owner January 29, 2024 01:59
Copy link

github-actions bot commented Jan 29, 2024

✔️ No visual differences introduced by this PR.

View Playwright Report (note: open the "playwright-report" artifact)

@toasted-nutbread
Copy link
Author

Something this change makes more obvious is situations where there are implicit dependencies that are easy to miss stubbing for tests. For example, AnkiNoteBuilder has a partial dependency on API, which was previously accessed via yomitan. Now all of the potential situations where this would be used don't actually have test cases at this time, but they could. So there is now a MinimalApi class which stubs it. For now this is empty, but it can be populated later if the need arises.

djahandarie
djahandarie previously approved these changes Jan 31, 2024
Copy link
Collaborator

@djahandarie djahandarie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I sort of feel like "application" (or "yomitan" previously) is not really a valid unit of abstraction / grouping, it should probably be split up a bit differently. But this is just a hot take, haven't really thought about if there is some salient division of stuff in there, or a less-generic sounding category name.

@djahandarie
Copy link
Collaborator

(Merge conflict)

@toasted-nutbread
Copy link
Author

I didn't name it "Extension" because that is somewhat ambiguous with the overall concept of a "web extension". I went with "application" instead because it's generic and the goal of the class is that it hosts generic components of the class that contain state and are shared around the different parts of the codebase. It kind of serves as an initialization point and an easier way to group a few communication types together (the API stuff).

You're right that it's not a perfect abstraction, and this is reflected by some places being passed api and the likes directly. I'm open to additional suggestions on how to approach this if you feel it's not the right direction. There are a few things that I intend to do that come after this step which should help separate the functionalities handled in the class as it is in this PR, but I didn't want to go overboard making a lot of changes immediately.

The biggest previous design issue that I am trying to address with this is the idea that "yomitan" is not initialized as part of the main function, which makes the dependency map a bit odd. I.e. a lot of things import {yomitan} when they really don't need to, they just need a reference passed to the instance.

@djahandarie djahandarie added this pull request to the merge queue Feb 1, 2024
Merged via the queue into yomidevs:master with commit dfd42ba Feb 1, 2024
5 checks passed
@djahandarie djahandarie added the kind/meta The issue or PR is meta label Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/meta The issue or PR is meta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants