Hello – I’ve been working with Defold now in my spare time on a project for a while and I am about to go in and overhaul some of the subsystems that I think I may have built incorrectly the first time. Apologies if this general a question isn’t a good fit for the forum.
The domain model I have come up with is below. The main idea it is trying to capture is that people, buildings and vehicles in a town may or may not have Insurance Policies.
The question I have is - what is the best way to implement the relationship between Policy Instance and instances of Insureble in Defold?
I was thinking to give each Policy Instance a url attribute that would allow it to message the Insurable item it references – and to also have a url on the Insurable item referencing the policy.
The use case I am a little concerned about is when there is an accident I need to determine from the list of Insurable instances which insurance policies they have so I can determine how much money the player can collect.
The way I can do this efficiently is to have a “Global” table which links Insurable instances to policies and policies to products so that I can iterate through and calculate this whenever needed.
However this approach doesn’t “feel” right – it feels like there is a more natural message-passing style way to accomplish this.
What I’ve tried to do before is to iterate over the Insurable items and send a message to each Policy to return its details and then aggregate in some way, but it ends up having to pause and wait a cycle before the information is ready and I have to thread the info up to the GUI in a kind of strange way.
I guess I am still kind of stuck in “Object Oriented” thinking where I want to rely on an object graph and behaviors to implement this system.
Hopefully this question makes sense – please let me know if there is anything I can clarify.
Thanks!
Alex