I am running two separate programs which are similar enough that they share a lot of code. I run these programs often and after I evaluate the output. This is a very fluid process and everytime is different from the last time.
Currently I write a script named something like: "temp_evaluate_program_A" and then I will copy it to "temp_evaluate_program_B" and change a few lines, along with writing a lot of code on the fly. Often the code isn't very readable and only parts of it will ever be reused. This seems suboptimal as I get a lot of duplication.
What do other people do in these fluid situations where there is scope for sharing code between these related programs and reusing the code over time but the scope is limited.