I am making a music app, where the main file format the user can save to is a Song. When the user tries to start or open a new song, I want to check first whether the current song has been changed, and warn the user if it has. My question is, what is the best way to check for changes to a file?

The most obvious way I can think of is have a "changed" flag in Song objects, which gets flagged every time some operation is performed on the Song. Then when you need to check, you just check the flag.

I'm wondering if this is the best way? It seems like it could be cumbersome, if every single action that can change a song will need to remember to set the changed flag when it gets called. The number of actions could be pretty large. It feels like it would be nice if I could abstract it out so actions don't have to worry about the changed flag, they can just perform the action.

I'd love to hear how others have done it in their apps and any general tips