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

Use stringifiers to eliminate the need for duplicate "real" and "reference" properties #250

Open
ekolis opened this issue Aug 31, 2022 · 10 comments
Assignees
Labels
breaking This change will break savegame compatibility. technical debt Things that would make the code cleaner but deliver little to no value to users.
Milestone

Comments

@ekolis
Copy link
Owner

ekolis commented Aug 31, 2022

What needs to be cleaned up?

If I can make a stringifier that takes a mod object or referrable and prints its ID when serializing (and looks up the ID when deserializing)...

How will this benefit us?

...then we won't need all those silly duplicate properties on various objects, the real object properties and the reference properties! That will clean up a lot of code!

Plus the savegames will get a bit smaller without all those silly ID properties that are the only property of the references being serialized...

Heck, we might not even need the reference classes, since the only reason they exist is to support serialization...

What potential drawbacks are there to making this change?

We have to deal with lots of different types of objects. I don't think stringifiers can be generic types. So unless there's a way to handle all mod objects and all referrables using the same two stringifiers, this might not be possible.

Plus there are a LOT of properties...

@ekolis ekolis added the technical debt Things that would make the code cleaner but deliver little to no value to users. label Aug 31, 2022
@ekolis ekolis added this to the future milestone Aug 31, 2022
@ekolis ekolis added the breaking This change will break savegame compatibility. label Jan 12, 2023
@ekolis
Copy link
Owner Author

ekolis commented Jan 12, 2023

I wonder if the new C# generic attributes will let stringifiers handle generic types?

@ekolis
Copy link
Owner Author

ekolis commented Jan 28, 2023

Wait, aren't there times we do want to store a real object, like a design when it's being created?

@ekolis
Copy link
Owner Author

ekolis commented Oct 7, 2023

I suppose those could be marked with a special attribute. That would also prevent unexpected objects from being inserted into the game state!

@ekolis
Copy link
Owner Author

ekolis commented Oct 24, 2023

As it turns out, I was able to do this using GameReference and ModReference attributes hooked into the serializer rather than stringifiers.

These changes will be included with the changes for #272.

@ekolis ekolis modified the milestones: future, alpha-10 Oct 24, 2023
@ekolis ekolis self-assigned this Oct 28, 2023
@ekolis ekolis pinned this issue Oct 28, 2023
@ekolis
Copy link
Owner Author

ekolis commented Jan 13, 2024

Actually, this didn't quite work out; there is a need for a two step deserialization process where first all the objects are instantiated, and then they are all linked together via references. I haven't been able to get that working without the reference properties yet.

@ekolis
Copy link
Owner Author

ekolis commented Jan 21, 2024

Perhaps it's time to create some proper view models, rather than just using the models themselves for that purpose. That way the models could contain the IDs only and the view models could contain other view models. But view models are supposed to be linked to a specific view as well as a specific model, aren't they? That would lead to a lot of duplicate view models...

@ekolis ekolis unpinned this issue Feb 9, 2024
@ekolis
Copy link
Owner Author

ekolis commented Jun 9, 2024

#292 is the view model issue

@ekolis
Copy link
Owner Author

ekolis commented Jun 9, 2024

View models are linked to a specific view. They're not necessarily linked to a specific model; a view model could contain data from zero, one, or many models.

@ekolis
Copy link
Owner Author

ekolis commented Jun 9, 2024

Really the reference properties should go in a data model, and then the actual properties would go in the domain model, and computed properties would go in the domain model and/or the view model depending on where they're needed. Separating ou the reference properties into the data models would enforce the two step loading process.

@ekolis
Copy link
Owner Author

ekolis commented Jun 9, 2024

data models #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break savegame compatibility. technical debt Things that would make the code cleaner but deliver little to no value to users.
Projects
Status: In progress
Development

No branches or pull requests

1 participant