15
QuizMultiple Choice

Test: Design and Development

Question 15 • SC-Fundamentals of Computing - Content Recovery - Design & Development

According to programming best practices, how should you handle code that needs to be repeated several times in a program?

Answer
A
Have the code appear only once in the program and reference it when it is needed.
B
Store the code on a website and reference the website when it is needed.
C
Store the code only in a code library, not in the actual app's code.
D
Copy the code as many times as needed so that each usage is separate.

Explanation

Repeated code is best placed in one reusable function or similar structure, then called wherever it is needed. This avoids duplication, makes updates easier, and helps prevent inconsistencies. Choice A describes this approach: have the code appear once and reference it when needed.

AI-written and checked against the verified answer.

Previous
Next