database - Rails calculation model structure -


i trying put model structure performing various calculations, formulas stored within models.

currently, have operand model, connected via many-to-many operations model. works fine long can simple calculation (i.e. without intermediate steps).

where have problem if need (for example) subtract result of 1 operation result of another. i'm aware use second model perform calculations on operations, run same problem further chain (i.e. if need perform operation on result of calculation).

as such, need way nest operations - i.e. operation take operands normal operand operand model, or result of operation. there way operations model self reference this?

thanks!

this more of object modeling question rails question -- , without understanding domain models in more detail i'm not sure can great deal.

but think calculators , how i've seen simple sets of operations/operand programming work, there have been couple patterns i've seen may helpful:

  1. do have 'current result' model stores results after each operation performed? i'd think each operation performed on 'current result' model , store whatever current result is.

  2. i've seen situations idea of 'register' used temporary storage intermediate results. 'store register 1', example, operation itself. if developed @ 'register' object store results , fetch them (or perform operation on , leave result in register) may helpful.

does make sense in domain?


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -