Co-related quantities

From W3C XForms Group Wiki (Public)
Jump to: navigation, search

This is where two or more quantities are related to each other, e.g. X = Y * Z where X is in euros, Y is in dollars and Z is the exchange rate. If two of these quantities are known then the third can calculated from them. In particular, on a business trip to the United States, you might use cash for meals and a credit card for the hotel. The exchange rate for the cash payments is given by the rate you got when you bought the dollars at the airport, so you can then work out the equivalent cost in euros. For the hotel, your credit card statement may just give the amount paid in euros, leaving the exchange rate to be calculated.

One approach to this is to use a declarative representation of the relationship between the co-related quantities. This can be used to solve for missing quantities or to check for errors when all the quantities have been provided. It isn't always possible to solve the equation unambiguously, e.g. if Y = X * X and Y is 4 then you don't know whether X is 2 or -2. Even if the equation can be solved unambiguously, the cost of the equation solver may be considered to be too expensive. An alternative is to ask the application developer to provide the solution, e.g. Z = X / Y. This complicates dealing with dependencies between quantities as it introduces a kind of circular dependency. This can be dealt with but complicates the algorithms for topological sorting of dependencies, e.g. through an explicit notion of defined and undefined values.