4

I've recently learned how committing of the Save Data to file works in my project.

The file is updated w/ _each change_ made to the settings.

Worse yet - the file is updated even when _no actual change_ is made due to the setting already being at its highest / lowest value possible.
/*
e.g. 5 is maximum sound volume.
- You try increasing the sound volume.
- Setting can't get any higher, so remains unchanged.
- *Update the Save Data*.
*/

What kind of abusive masochist would do that?

// Yes... there's always blame.

Comments
  • 3
    I don't think this is a big failure, it prevents you to build a whole is_changed functionality per setting
  • 2
    @retoor Depends on how you look at it.

    Thing is, certification-wise, there are rules against such practices because this unnecessarily ages the hardware.
  • 1
    @D-4got10-01 I'm currently doing this unironically

    already had a SSD fail without such functionality though and turns out SSDs don't slow down and instead just totally die out of nowhere so that was annoying
  • 1
    @jestdotty Losing your storage certainly sucks.

    With SSDs, you should be able to check their health using programs such as CrystalDiskInfo or something similar.

    SD Cards && flash drives, on the other hand, just die w/o warning.

    AFAIR they switch to read-only state just before dying, so you can still recover the data, but still.
  • 2
    Okay but if the optimization is specifically about avoiding writes, I'd just hold onto the serialized data and avoid writing back to the file if the strings are identical.

    This type of change tracking either comes for free with your reactive UI framework or isn't worth building on general. I'd only ever consider manually adding it to inputs if there's a single specific kind of input that falsely triggers a change event very often.
  • 1
    @lorentz There are many approaches to this.

    Yours sounds good, too.

    You could even get away w/ a simple solution of committing to file when exiting the Settings Menu regardless of whether or not an actual change has been made.

    But not this... not saving to file w/ each update of some value.
Add Comment