Consider the following code: int f(int[] a, int[] b) { int sum = 0; for (int i
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider the following code:
int f(int[] a, int[] b) { int sum = 0;
for (int i = 0; i < a.length; i++) sum +=a[i]; for (int j = 0; j < b.length; j++) sum +=b[j]; returnsum;
}
a. Which code smellis present in this code? (Choose exactly one.)
[ ]duplicatecode [ ] long parameterlist [ ]longmethod [ ]none
b. Which refactoring would you choose to eliminate the smell (Choose exactlyone.)
[ ]extractmethod [ ] introduce parameterobject [ ] replace method withmethodobject [ ] nonerequired
c. What will the code look like after the refactoring (ifrequired):
Related Book For
Computer Organization And Design The Hardware Software Interface
ISBN: 9780123747501
4th Revised Edition
Authors: David A. Patterson, John L. Hennessy
Posted Date: