Simberon Design Minute
 

Automatic Complexity

I was once working on an application that required a number of calculations to be performed and automatically updated whenever any of the input variables changed. I decided that the best way to handle it was to create an automatically updating calculation engine. I created objects that could hold values. I then created objects that could add values from other objects and produce a result. I had other objects that could multiply. I tied the whole thing together with a dependency mechanism. Now, when you dropped a value into one of the inputs, it would automatically calculate the answer. It may have been clever but it turned into a programming nightmare. I had transformed what might have been two or three lines of code into 15 to 20 objects. I couldn't easily put in breakpoints or single step. Every time I needed to debug the calculation I had to pull out a drawing and trace through it. In hindsight, it would have been better to just drop the calculation into a method that I could more easily see and manage.

Download