Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Considering SaveProtected --> RequiresSave #62

Closed
olmobrutall opened this issue Jan 30, 2016 · 0 comments
Closed

Considering SaveProtected --> RequiresSave #62

olmobrutall opened this issue Jan 30, 2016 · 0 comments

Comments

@olmobrutall
Copy link
Collaborator

Speaking about SaveProtected in #61 I think I can simplify the concept:

This is how it currently works:

  1. Registering Save-like on an entity sets SaveProtected
  2. The developer can override SaveProtected if he needs to.
  3. At start time the framework checks that RequiresSaveProtected(EntityKind) == SaveProtected

Note: RequiresSaveProtected returns true for [String, Shared, Main] and false for [System, SystemString, Relational, Part, SharedPart].

But I've been illuminated with a simpler algorithm that maybe is easier to remember.

  1. Registering an entity sets RequiresSave to CalculateRequiresSave(EntityKind) using the same logic.
  2. The developer can override RequiresSave.
  3. At start time the framework checks all the entities that have RequireSave==true having at least one Save-like operation registered.

For the vast majority of cases the change in behavior will be transparent, except than when you forget to register a save you'll get a simpler to understand error like

'YourEntityName' is 'Main' and requires a save operation but, none has been found. Consider one of the following options:
* Register a save operation for `YourEntityName` using `save` snippet.
* Change the EntityKind of `YourEntityName` to one that does not require save.
* Exceptionally, call 'OperationLogic.RequiresSave(typeof(YourEntityName), false)' to override the value.

Does this looks like a good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant