I'm just curious to see what you guys think about it. I heard that a bunch of answers went around the office, and I want to see if yours is possibly the best.
Question:
You have two functions described below:
function one()
{
A();
B();
C();
}
function two()
{
A();
D();
C();
}
How would you rewrite this (something counts, you can create classes, variables, other methods, whatever) to reduce code duplication?
Each of the methods called changes to variables that other functions should use. Methods A () B () and C () are already defined.
source
share