A blink comparator quickly exchanges two images that are largely the same. The few places where they differ "blink" which the human visual system is very sensitive to. It was first used in astronomy to look for planets and comets by putting two photos of the same patch of sky but taken on different nights into a device that rapidly fed one image to the right eye, then the other to the left eye.
Applied to software, it is typically used on data or source code. Bring up two nearly identical functions in a tabbed window setting. Alternately click the tabs as quickly as possible. Any differences show up by blinking. For source code, one may have to adjust indents or vertical white space to line up the parts that are the same. This is a particuarly powerful way of dealing with legacy code that accomplished reuse through CopyAndPasteProgramming
. Code that looks the same is typically slightly different, often only on the type of variables, etc. Modern diff engines have reduced the need for a BlinkComparator
, but both are useful.
is a good first step to refactoring copy & paste code. The code that doesn't blink is what can be abstracted, the code that does becomes arguments to a function containing the common parts, or clues to the structure of a class hierarchy.
Another way to get a similar result is to print the code sections on thin paper, lay one over the other, and hold them up to the light.
But you'll get the reputation for being a odd folk. Don't forget to swap the order of layering to reduce the chance that the front layer will hide a difference between the back.
Caveat: The exchanging may in no case lead to a temporary blank. Both views must swap directly without e.g. an intermediate white/grey/black screen as one so often sees on a Window redraw. This is because of ChangeBlindness
. The human visual system will immediately lose its comparison ability.
Pluto was found this way.
You can also put the images side by side and cross your eyes as though you're viewing a stereogram.
Note that this feat of our visual system depends on the continuous change of the two compared images. If even the smallest blank screen is shown between the images to compare (say if your screen refresh clears one image before rendering the second one), then the change will be lost completely. This is called ChangeBlidness?
. You will overlook even very large changes between the images. -- GunnarZarncke
See also: DiffAlgorithm