tags:

views:

55

answers:

2

There are many files in our project that would call a Facebook api. And the call is complicated, spanning usually 8 lines or more, just for the argument values.

In this case, we can make it into a function, and place that function in a common_library.php, but doing so would just change the name of the function call from the Facebook API function to our name, and we still need to repeat the 8 lines of arguments. Each time, the call is very similar, but with slight variations to the argument values.

In that case, would copy and paste be needed no matter what we do?

+1  A: 

"Each time, the call is very similar, but with slight variations to the argument values."

If you pass differing parameters each time, you're not actually repeating yourself. The fact that the function call spans 8 lines is more concerning, and there are many ways to try and ameliorate that. However, without more information on what this function actually does, it's hard to offer any advice.

Adam Wright
+1  A: 

Introduce Parameter Object might be the best solution for this.

Carl Manaster