A fundamental design principle, I know because I violate it frequently, is to always operate on a model of the data, not on the data itself.
In my job, I write code to manipulate an ultrasound image or sequence, with measurements, cursor positions, scaling, image processing, etc. It only gets worse and worse, the longer I interface to the data itself, rather than interfacing to a idealized model of the data, and subsequently displaying the idealized data, such that the idealized data would never have to be converted, but only re-realized onto a new platform (a new scale, new dimensions, sector angle, hardware, etc).
For example, if a measurement on the ultrasound image is at (x,y), then it needs to be converted to the polar coordinate (distance,angle) distance from origin and angle, before performing any computations, and the positions need to be saved in the model's (distance,angle). To save a position, the image (x,y) is converted FIRST.
This allows any image in (x,y) to be produced, and manipulated, and the computations only need to be done once, in (distance,angle) polar coordinates, in the original model's representation.
No comments:
Post a Comment