The development process
No program is born finished, and none works on the first try. Imagine your school's attendance app crashes on the first morning of the semester, with 2,000 students trying to check in. Between the initial idea and a reliable program there is a process with stages that repeat: editing, running, testing and correcting. Mastering that process, and not just knowing how to write code, is what sets professional programmers apart.
The development cycle
These phases of program development are out of order: (a) testing the program with different data, (b) editing the source code, (c) debugging found errors, (d) running…
These phases of program development are out of order: (a) testing the program with different data, (b) editing the source code, (c) debugging found errors, (d) running the program. Put them in a logical order and explain what is done in each phase, taking into account that testing may require going back a step.
Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the…
Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the user.
The cycle also applies to a whole project: a program built over several weeks goes through the same loop again and again, in small steps (iterative and incremental development). Back to the start: that attendance app is only trustworthy after many passes through edit, run, test and debug.
The figure shows the software development workflow cycle, but one of its stages is covered with a question mark, as shown in the figure. State which stage is missing…
The figure shows the software development workflow cycle, but one of its stages is covered with a question mark, as shown in the figure.
State which stage is missing from the cycle, what it consists of, and why the "no" arrow sends the work back to editing the code.
Topic Challenge. As a junior software analyst, you are going to design a Python script (you can use a free web environment like Replit) that evaluates daily energy costs…
Topic Challenge. As a junior software analyst, you are going to design a Python script (you can use a free web environment like Replit) that evaluates daily energy costs to promote household savings.
Follow these three phases:
-
Data gathering: Go to the website of your local electric utility or the U.S. Energy Information Administration (EIA) and record the official price ($\$/\text{kWh}$) for $6$ different time slots today.
-
Design and coding: Apply the software development process. First, sketch the algorithm and translate it into Python. The program must store the data in a list, use an iterative loop to calculate the average daily cost, and use conditionals (
if-else) that issue alerts when the price exceeds the threshold of $0.18$ dollars/kWh. -
Debugging and final product: Test with edge cases and fix runtime errors. Write a brief report that includes the clean, commented code, a screenshot of the console output, and two efficient consumption proposals for your home based on your data.
Assessment criteria:
-
Rigor in the development process (prior algorithmic design, textual coding, and debugging).
-
Correct use of control structures (sequential, conditional, and iterative) and language syntax.
-
Accuracy in processing real data and feasibility of the energy conclusions.
Types of error
Two more error types are in the AP® course. A run-time error happens while the program is running, often only with certain data: dividing by 0 or reading a list item that does not exist stops the program midway. An overflow error happens when a calculation produces a number too big for the bits the computer uses to store it. A compile-time (syntax) error stops the program before it starts; a run-time error stops it after it has started.
Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the…
Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the user.
Distinguish between a compile-time error (the program does not even start) and a runtime error (it starts but fails with certain data), giving an example of each type.
Distinguish between a compile-time error (the program does not even start) and a runtime error (it starts but fails with certain data), giving an example of each type.
Explain the difference between a syntax error and a logic error, giving an example of each in a program that calculates the mean of three scores. Which of the two types…
Explain the difference between a syntax error and a logic error, giving an example of each in a program that calculates the mean of three scores. Which of the two types prevents the program from running, and which allows it to run but produces incorrect results?
Designing test cases
Explain what a test case is and write two test cases for a program that adds two numbers: one with normal values and one with a special value, stating the input and…
Explain what a test case is and write two test cases for a program that adds two numbers: one with normal values and one with a special value, stating the input and expected result for each.
A program that divides two numbers works fine in almost all tests, but fails when the divisor is 0. Explain what boundary values or edge cases are in testing, why they…
A program that divides two numbers works fine in almost all tests, but fails when the divisor is 0. Explain what boundary values or edge cases are in testing, why they must always be tested, and state two other values with which you would test this program.
To test a program that applies a discount to people aged 65 or over, define three test cases: one with a normal value, one with the exact boundary value, and one with an…
To test a program that applies a discount to people aged 65 or over, define three test cases: one with a normal value, one with the exact boundary value, and one with an invalid value (negative or impossible age), with the expected result for each. Justify your choices.
Design a test plan for a program that asks for two numbers and displays their quotient: create a data table with at least six test cases (pairs of input values,…
Design a test plan for a program that asks for two numbers and displays their quotient: create a data table with at least six test cases (pairs of input values, including normal, boundary, and invalid values), the expected result for each, and what the program should do if the input is invalid. Justify the choice of each case.
The school's intranet implements an authentication module with the following requirements: Username: 4 to 12 alphanumeric characters, case-insensitive. Password: between…
The school's intranet implements an authentication module with the following requirements:
-
Username: 4 to 12 alphanumeric characters, case-insensitive.
-
Password: between 8 and 16 characters, case-sensitive, with at least one digit and one special character.
-
Security: temporary account lockout for 15 minutes after three consecutive failed attempts.
Design a rigorous test plan using a table with at least six test cases designed by you. For each case, you must specify: identifier, input values (username and password), previous system state, expected result, and what specific logic, boundary, or security risk you are validating.
Test cases are also how you check an algorithm before trusting it. Write them before you run the code, and add edge cases such as an empty list or the value 0.
Debugging techniques
Explain what a trace or log message is in a program and how it helps to find an error (it allows you to see which path the program took and with what values).
Explain what a trace or log message is in a program and how it helps to find an error (it allows you to see which path the program took and with what values).
A loop in a program never stops. Explain where you would place temporary print statements to diagnose it (inside the loop, displaying the control variable in each…
A loop in a program never stops. Explain where you would place temporary print statements to diagnose it (inside the loop, displaying the control variable in each iteration) and what you would look for in those statements to find the cause.
In the billing system of a school co-op, it has been detected that when issuing the monthly invoice, the total amount payable for some members is incorrect. You have the…
In the billing system of a school co-op, it has been detected that when issuing the monthly invoice, the total amount payable for some members is incorrect. You have the following system logs available:
-
Member 101: 2 purchases of 15.00 dollars -> Total billed: 30.00 dollars (expected: 30.00 dollars).
-
Member 102: 1 purchase of 50.00 dollars with a 10 % promotional discount (5.00 dollars) and a 3.00 dollars management fee surcharge -> Total billed: 47.50 dollars (expected: 48.00 dollars).
-
Member 103: 1 purchase of 20.00 dollars and 1 item return of 5.00 dollars (-5.00 dollars) -> Total billed: 25.00 dollars (expected: 15.00 dollars).
-
Formulate a justified hypothesis about the logic or order-of-operations bug that explains the error for Member 102 and Member 103.
-
Design the debugging strategy to confirm your hypotheses: indicate what minimum test data you would input to isolate the bug, at what points in the execution flow you would place breakpoints, and what specific variables you should inspect step by step.
Modularizing, refactoring and documenting
Versions and documentation
A version is a saved snapshot of the code (1.0, 1.1, 2.0). Keeping versions, for example with Git, lets you go back to the previous one if the newest version performs worse. Documentation (comments plus a user guide) explains what the program does, how to use it, and why each part exists. Without it, teammates cannot safely change code they did not write, and the program decays over time.
Working as a team
In pair programming, one student types (the driver) while the other reviews (the navigator), and they swap roles. A code review means a teammate reads your changes against a checklist (clear names, comments, passes all tests) before they are accepted. Plan the project in milestones, such as design, first working version, full testing and release, and move on only when the tests for that milestone pass. Teams with different perspectives catch more problems for more users.
Programs have versions (1.0, 1.1, 2.0, etc.). Explain the purpose of keeping versions of code and what you can do if the latest version performs worse than the previous…
Programs have versions (1.0, 1.1, 2.0, etc.). Explain the purpose of keeping versions of code and what you can do if the latest version performs worse than the previous one.
Documentation accompanies a program. Explain at least two things it should cover (what the program does and how to use it) and why undocumented software degrades poorly…
Documentation accompanies a program. Explain at least two things it should cover (what the program does and how to use it) and why undocumented software degrades poorly over time when a team works on it.
Explain what modularization of a program is (dividing it into functions or modules) and analyze two advantages it offers when development is carried out by a team of…
Explain what modularization of a program is (dividing it into functions or modules) and analyze two advantages it offers when development is carried out by a team of several people: think about division of work, testing, and error localization.
Explain what refactoring is (improving code without changing its external behavior) and describe two typical refactorings (renaming variables with clear names,…
Explain what refactoring is (improving code without changing its external behavior) and describe two typical refactorings (renaming variables with clear names, extracting a function from repeated code), with an example of each.
A code snippet uses the variables x, y2, and zzz to store the price, sales tax, and total. Rewrite these names meaningfully and explain why choosing descriptive names…
A code snippet uses the variables x, y2, and zzz to store the price, sales tax, and total. Rewrite these names meaningfully and explain why choosing descriptive names helps prevent errors (making the code self-documenting).
Two members of a team edit the same project file at the same time and, when merging changes, a conflict arises. Explain what a merge conflict is, how it is resolved…
Two members of a team edit the same project file at the same time and, when merging changes, a conflict arises. Explain what a merge conflict is, how it is resolved (reviewing both versions and deciding), and which two team habits prevent it (dividing work by modules, integrating changes frequently).
A group of three students is going to develop an attendance tracking app for the school over ten weeks. To avoid delays and last-minute failed deliveries, you must…
A group of three students is going to develop an attendance tracking app for the school over ten weeks. To avoid delays and last-minute failed deliveries, you must structure the team's working methodology:
-
Design a schedule organized into four verifiable milestones or deliverables, explaining what objective criteria must be met before authorizing the transition to the next milestone.
-
Define a formal peer review protocol (code review): establish who reviews whose code, what minimum quality checklist must be passed before accepting any changes, and how disagreements are managed.
-
Establish and justify a "code freeze" policy: in which week it must be activated, what type of modifications are strictly prohibited from that moment on, and what exclusive tasks the team must undertake until the final delivery.