refactor(job): Implement polymorphic behavior on creation for jobs #134
No reviewers
Labels
No Label
Blocked
Bug
Contributions welcome
Did not do
Errata
Feature request
Fixed
How To
Invalid
Needs design
No resolution
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Providers
Digital Ocean
Providers
Hetzner
Refactor
Severity
High
Severity
Low
Severity
Medium
Source
Community
Source
Core Team
Source
Stakeholders
Translations
Under investigation
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: SelfPrivacy/selfprivacy.org.app#134
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "server-settings"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
bool canAddTo(final List<ClientJob> jobs)
function to override from abstract ClientJob. It Allows every job type specify how and when exactly they can be added to global jobs list.void addJob(final ClientJob)
function to avoid misunderstanding and misusage of cubit's interface.Looks good, but we should evaluate if using
equatable
forcanAddTo
checks would make code cleaner.@ -31,1 +32,4 @@
@override
bool canAddTo(final List<ClientJob> jobs) =>
super.canAddTo(jobs) && !jobs.any((final job) => job is RebuildServerJob);
These validations look awful. We have
equatable
in our project for that.https://pub.dev/packages/equatable
This library is used in all of our cubits state to compare if they are the same. Should we use it here too?
We can't use equatable for it, because it bears different semantics. Even its documentation page says
What
canAddTo
does is not simple checking for equality, if you read these checks again you will see they have different meaning, none of them is checking for absolute equality of job instances, at least because jobs have unique ids.The issue is the looks of the solution and I actually don't know how to avoid this. I mean, previously these checks were in JobsCubit, now they are in the jobs themselves, the same approach.
Equatable covers exactly same logic you see using in these checks. Just drop to
props
fields you want to check, and that's it.Ah, well, I see that during check you do not construct a Job object, and you nave nothing to compare yet.Nope, just pass
this
A simpler way to say it, canAddTo bears business logic semantics, not technical, so we can't plainly compare instances of Job types for absolute equality
973c7d3e8a
to0b5f8b6920