Developing Applications and Automating Workflows Using Cisco Platforms (DEVASC) — Question 13
A developer is reviewing a code that was written by a colleague. It runs fine, but there are many lines of code to do a seemingly simple task repeatedly. Which action organizes the code?
Answer options
- A. Refactor the code by removing any unnecessary tests.
- B. Reverse engineer and rewrite the code logic.
- C. Using functions, rewrite any pieces of code that are repeated.
- D. Modify the code to use loops.
Correct answer: C
Explanation
The correct answer is C because utilizing functions allows for code reuse and better organization by encapsulating repetitive logic into manageable units. While options A and B might improve the code in other ways, they do not specifically address the issue of repetition. Option D could also help but does not leverage the benefits of functions to encapsulate logic effectively.