GitHub has released Scientist 1.0, a Ruby library that assists with code rewrites. It shows developers what will happen when rewritten code is executed, compared with how the original code ran. “It works by creating a lightweight abstraction called an experiment around the code that is to be replaced,” GitHub engineer Jesse Toth said. “The original code — the control — is delegated to by the experiment abstraction, and its result is returned by the experiment. The rewritten code is added as a candidate to be tried by the experiment at execution time.”
GitHub says that developers should follow a similar procedure when rewriting code in any programming language. “Even if Ruby isn’t your language of choice, we’d still encourage you to apply Scientist’s experiment pattern to your system,” said Toth.