What qualities characterize a well-constructed program?
A well-constructed program produces correct results, handles invalid inputs safely, is readable, modular, testable, documented, and maintainable.
Study 04 — Program Construction and Problem Solving with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What qualities characterize a well-constructed program?
A well-constructed program produces correct results, handles invalid inputs safely, is readable, modular, testable, documented, and maintainable.
What should a problem specification define?
It defines the data received, the result required, valid assumptions, and what should happen when input is invalid.
What is decomposition in program construction?
Decomposition divides a large problem into smaller tasks that can be represented by algorithms, functions, or modules.
What is an algorithm?
An algorithm is a finite, ordered set of sufficiently precise steps for solving a problem.
What is an invariant?
An invariant is a fact that remains true during an algorithm. For an averaging loop, the running total equals the sum of scores processed so far.
Why use meaningful names in code?
Meaningful names communicate purpose, making code easier to read. For example, `average_score` is clearer than `x`.
What does a function interface specify?
A function’s interface describes its inputs, outputs, and error behavior. For `calculate_average`, the input is nonempty scores, the output is numeric, and an empty sequence raises `ValueError`.
What do high cohesion and low coupling mean?
High cohesion means a module’s elements support one main purpose. Low coupling means the module depends on as few details of other modules as possible.
What information does a test case specify?
A test case records the input, expected result, actual result, and whether the test passes or fails.
What are boundary test cases?
Boundary cases test values at or near limits, such as scores of `0` and `100` when the valid range is 0 through 100.
What does a unit test check?
A unit test checks a small unit of behavior, usually a function or method, and states one clear expectation.
What is the purpose of regression testing?
A regression test records behavior that must continue to work after changes. Existing tests should be rerun, and important discovered defects should receive new tests.