-
Notifications
You must be signed in to change notification settings - Fork 18
Description
The purpose of the PendingTasksFactory is to construct instances of PendingTask subclasses when Wendy has decided it is time for that PendingTask to run.
Problems with PendingTasksFactory:
- Boilerplate code to write
- Annoying to maintain it each time you modify a
PendingTaskto add/remove/change dependencies. - Creates bugs if you forget to add to the
PendingTasksFactorywhen you create newPendingTasksubclasses - The reason
PendingTask.tagexists is to be used withPendingTasksFactory. I describe thetagproperty as "in the way" as it doesn't identify the data and how it should be run by Wendy, it identifies the subclass. The tag is still required, but housing the information someway else would be a benefit to the API.
Can we remove the need to create a PendingTasksFactory?
-
No: As this issue explains, there needs to be a way to construct instances of each
PendingTaskalong with their dependencies. -
Yes: Maybe we could create a compile time annotation processor to generate a
PendingTasksFactoryfor you? Android libraries, especially those like Moshi, are able to take a constructor of a class and generate code to construct instances of that class. Instead of using aPendingTask.tagproperty, we could create an annotation that has a property inside of that annotation fortag. This solution would cross off each item on the list above of problems with the factory.