Let's say there are two variables a & b, both a & b would have a value between a predefined range.

a = x1 to y1 (range)
b = x2 to y2 (range)

Variable a & b are interdependent, if the value of a is x1 then value of b would be x2 and vice versa.

For example.

a = 5 to 35 
b = 40 to 15

if value of a here is 5 then value of b would be 40 and if it increases to 35 then b would be 15. The values would obviously increase or decrease in continuous manner based on what other value is.

What's the most optimum way to solve this pragmatically.


As you describe it, b is not a variable at all. Instead, it is a linear function of a. The solution is to create a method that computes the value for b from a and use it wherever you were going to read b.

(If you also wanted to write b, then you need to do more work and write another method which performs the opposite calculation and then writes arather than b.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.