In my 3D drawing system, I have two classes: a model class which represents 3D models which have been imported with third party libraries, and a model cache class which represents the data of the model to be serialised into a binary cache (which contains some extra information that I need as well).
The problem I am currently solving is cache invalidation. Given that the model file has been modified after the cache file, I am checking whether the meshes or the scene graph (node structure) has been changed from the cache. The class which checks whether the cache data is valid/invalid, calculates hashes for both the newly imported model and the cache data.
The issue is, if for some reason the implementation of the cache data invalidation changes (i.e. if I decide to include some extra data in the hashing process), then these changes have to be reflected in the model hashing as well.
As I am currently working with multiple people in this project, there's a chance that someone could break this part of the code by making changes in the future. Is there a design pattern which could keep the hashing for both cache and model synchronised, or maybe make it obvious that you must make sure to change both parts of the invalidation (cache and model).
The implementation of all of this is in C++, and this is purely a theoretical question as I feel like I have come across this a few times before.
Aucun commentaire:
Enregistrer un commentaire