jeudi 22 novembre 2018

A good way to represent an object with multiple interconnected states?

I want to program a simple budget application. In my application, the budget is divided into budget periods (months by default, but it can be bi-weekly or weekly periods). In each period there is a list of spending categories. The user can perform different action on a category, like to record a spending, allocate budget, create new category, close existing category etc. So each category should have a different state for each period, but the changes for particular state of specific period should influence the category state of consecutive period (any change in spending/budgeting in January should change the state of a category in February). So each period should have a specific state of category that is belong to him and he can operate on, but the category itself should be able to see the changes that are made and perform changes in other states. Initially I was thinking to implement a category as a list of its states, but my gut telling me that it's not a good design. I would really like to hear if there is a better design/design patter that can be used here.

Aucun commentaire:

Enregistrer un commentaire