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

Simplify the workflow of NAPPA #72

Open
github-actions bot opened this issue Jun 27, 2020 · 0 comments
Open

Simplify the workflow of NAPPA #72

github-actions bot opened this issue Jun 27, 2020 · 0 comments
Labels
enhancement New feature or request project:library Issues related to the prefetch library for Android

Comments

@github-actions
Copy link

github-actions bot commented Jun 27, 2020

The workflow of NAPPA is complicated. For instance, the class Nappa has far too many responsibilities.

My suggestion would be to refactor this class, making it an access point to NAPPA and extract data management to other classes. These classes would be self-contained and have a single responsibility/purpose.

In addition to having many responsibilities, NAPPA frequently invokes secondary threads. This is due to Android development nature, as network requests and database accesses must be performed in secondary threads. In NAPPA, these threads are created using ScheduledThreadPoolExecutor.

All these aspects make the workflow of NAPPA difficult to follow and debug.

In PR #99 a first attempt to improve the readability was performed by extracting database accesses to Handler classes. The introduced flow consists of a caller, a handler and an executor. The caller is the class that needs to perform an access to the database or issue a network request. The handler will take the desired action, instantiate its executor and schedule it to run in a secondary thread. The executor then executes the given action and, if applicable, returns a callback to the caller, with the operation result. Each action is implemented with handlers and executors pairs. A handler may be invoked by another handler. The handler abstracts the calls to threads and execution. The caller only needs to provide the data and, if applicable, provide a callback.

There are more candidates to be extracted into handler/executor pairs. You can verify the existent handlers and executors here

@github-actions github-actions bot added the todo label Jun 27, 2020
@sshann sshann added enhancement New feature or request project:library Issues related to the prefetch library for Android labels Jun 29, 2020
@sshann sshann changed the title The workflow of the NAPPA library is a complicated... Simplify the workflow of NAPPA Aug 29, 2020
@sshann sshann removed the todo label Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request project:library Issues related to the prefetch library for Android
Projects
None yet
Development

No branches or pull requests

1 participant