Open rwillians opened 1 year ago
@rwillians I like the idea of having as many ops as possible supporting no-ops where possible. As a bonus can remove unnecessary conditionals that have to check for empty lists.
@rwillians maybe you could start with some ops that are adding boilerplate to your code and I can start with those
Related to #16
In order to keep the code simpler and more readable, in some cases I personally prefer creating no-ops (or is it null-ops? -- in a reducer, it means producing an operation like an
update
that will do no side effect to the db). This avoids conditional creation of ops and overkill extractions with conditions and/or pattern matching.The most common case, for me, is having a pattern match that might return null instead of an op. But there has been one case case where I used and updated that changed no fields (issue #16) -- this one was in Hatch, don't remember if there were any in TurtleOS.
Of course we could just wrap the returned list of ops with a function that filters no-ops (like reject null values or even filtering out Derive operations' structs based on some logic), therefore this isn't a blocker. But, I think this is something we could do on Derive's side the keep userland-code cleaner.
The sudo-code for what I'm suggesting would look like:
A use case example:
Another one:
It also makes it easier to do this:
Edit: updated sudo-code for filtering out no-ops, now allows for this use case: