You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of having a mutable EditService and having checks before operation to assert state (which is what we're doing relatively ergonomically with this @transaction_required annotation), we could utilize typestates. So, you'll call a function to start the transaction, and you'll receive a transaction object that can perform all the operations (and commit at the end).
This way, it's easier to use this API, since you don't have functions on your objects that have implicit requirements - you physically can't call transaction functions until you've started the transaction. Additionally, there's less room for errors when changing the API, such as forgetting the @transaction_required annotation, since required resources (like edit_id) would sit in the transaction object.
Additionally, by making the transaction object work with a context manager, we can have automatic committing when exiting a with ... block, which would make this even better
The text was updated successfully, but these errors were encountered:
Instead of having a mutable
EditService
and having checks before operation to assert state (which is what we're doing relatively ergonomically with this@transaction_required
annotation), we could utilize typestates. So, you'll call a function to start the transaction, and you'll receive a transaction object that can perform all the operations (and commit at the end).This way, it's easier to use this API, since you don't have functions on your objects that have implicit requirements - you physically can't call transaction functions until you've started the transaction. Additionally, there's less room for errors when changing the API, such as forgetting the
@transaction_required
annotation, since required resources (likeedit_id
) would sit in the transaction object.Additionally, by making the transaction object work with a context manager, we can have automatic committing when exiting a
with ...
block, which would make this even betterThe text was updated successfully, but these errors were encountered: