The situation is following:
- I need to keep a lot of objects (let's say
Food) in database (in my case it's MySQL). - Each object has a property
Statewhich is enumerable taking one of "FRESH", "STALE" or "SPOILED". - Each object changes its state according some schedule. For instance, an object
Bottle of milkis created withFRESHstate, but after 2 days it becomesSTALE, then after next 3 days it becomesSPOILED.
The question is: is there any pattern that allows me to control states of objects and change them accordingly? For instance, I can run some script every 30 minutes, select all the objects, inspect their states and change them. But this approach looks suboptimal, I'm trying to find out something better.
Aucun commentaire:
Enregistrer un commentaire