BaseJob: Use saved parameters instead of overriding apiPath(), query() and data() in each job class #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rather wide-reaching change; it doesn't affect clients, and is rather easy to understand though. The rationale for it is that virtual functions normally should describe polymorphism in behaviour, not in data. Given that the passed parameters end up in a type-agnostic
QNetworkRequest
, there's not much use in have those chunks of data separately. So what I've done is simply saving the already type-erased components ofQNetworkRequest
right at the moment ofBaseJob
construction. This saves numerous descendants ofBaseJob
from having to overrideapiPath()
,query()
and/ordata()
, instead taking them to do all necessary conversions in their constructors. The simpler cases (LogoutJob
for instance) become very trivial then; and the more complicated cases (seeSyncJob
) still have all request building complexity in a single method (the constructor, that is). And we're saving in runtime on virtual invocations, too.