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?
A.
Refactor the code by removing any unnecessary tests
B.
Using functions, rewrite any pieces of code that are repeated
When a developer encounters many lines of code doing repetitive tasks, refactoring the code to use functions is a standard practice. This reduces code duplication and enhances readability and maintainability. Functions encapsulate repetitive logic, making the code cleaner and more organized.
[Reference: Cisco DevNet Associate Certification Guide, Chapter on Software Development and Design ., , ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit