The development process
No program is born finished, and none works first time. 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 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.
Types of error
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 marks. 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 marks. 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.
A team member shows you the following C++ function to calculate the final price including VAT and apply a discount if the customer is a member, claiming: "If it compiles…
A team member shows you the following C++ function to calculate the final price including VAT and apply a discount if the customer is a member, claiming: "If it compiles without errors or warnings, it's impossible for it to fail at runtime; there's no need to test it":
float calcularPrecioFinal(float base, bool esSocio) {
float total = base;
if (esSocio = true) {
total = total * 0.90f;
}
total = total * 1.21f;
return total;
}
-
Reasonably predict the output of the function for a non-member customer (
esSocio = false) with a base price of 100,00 €. Does it match the expected behavior? Explain why the compiler does not reject it as an error. -
Justify, based on this example, the difference between what syntactic verification by the compiler guarantees and what dynamic software testing proves.
-
Propose the code fix and write a specific test case that demonstrates the bug if the fix were not applied.
Design a test plan for a program that asks for two numbers and displays their division: create a table with at least six test cases (pairs of input values, including…
Design a test plan for a program that asks for two numbers and displays their division: create a 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.
A programmer argues that "a one-line function does not need testing because it is self-evident" and presents this function written in C++: 1. Predict the function's…
A programmer argues that "a one-line function does not need testing because it is self-evident" and presents this function written in C++:
bool esImpar(int n) {
return (n % 2 == 1);
}
-
Predict the function's output for
n = 7,n = 0, andn = -7. Explain technically why an unexpected result occurs in one of them based on how the modulo operator (%) handles negative operands in this language. -
Fix the expression so that the function is mathematically correct for any integer.
-
Based on this case, refute the idea of dispensing with unit tests in short or seemingly trivial algorithms using two technical arguments.
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 cooperative, it has been detected that when issuing the monthly invoice, the total amount payable for some members is incorrect. You…
In the billing system of a school cooperative, 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 € -> Total billed: 30,00 € (expected: 30,00 €).
-
Member 102: 1 purchase of 50,00 € with a 10 % promotional discount (5,00 €) and a 3,00 € management fee surcharge -> Total billed: 47,50 € (expected: 48,00 €).
-
Member 103: 1 purchase of 20,00 € and 1 item return of 5,00 € (-5,00 €) -> Total billed: 25,00 € (expected: 15,00 €).
-
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.
A weather simulation script fails in approximately one out of twenty executions by throwing an unexpected exception, but when running it manually step by step, the…
A weather simulation script fails in approximately one out of twenty executions by throwing an unexpected exception, but when running it manually step by step, the failure is never reproduced (the program uses real-time API requests and a random number generation function).
-
Justify why this error is classified as non-deterministic (heisenbug) and identify the two sources of variability that prevent it from being reproduced at will.
-
Design a technical action plan to force the controlled reproduction of the bug without passively waiting for it to occur randomly (explain how you would handle the pseudorandom number generator and how you would decouple external network calls).
-
Once the defect is located and fixed, what testing procedure would you apply to certify that the error has completely disappeared and was not simply a statistical coincidence?
Modularising, refactoring and documenting
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 modularisation of a program is (dividing it into functions or modules) and analyse two advantages it offers when development is carried out by a team of…
Explain what modularisation of a program is (dividing it into functions or modules) and analyse 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 behaviour) and describe two typical refactorings (renaming variables with clear names,…
Explain what refactoring is (improving code without changing its external behaviour) 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, VAT, and total. Rewrite these names meaningfully and explain why choosing descriptive names helps…
A code snippet uses the variables x, y2, and zzz to store the price, VAT, 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).
The monitoring system for a greenhouse has been programmed in a single file within a single 400-line function. The code sequentially reads three analog soil moisture…
The monitoring system for a greenhouse has been programmed in a single file within a single 400-line function. The code sequentially reads three analog soil moisture sensors, calculates the average, evaluates thresholds, triggers a solenoid valve via a digital pin, logs the historical record into a text file, and sends an alert email if the moisture drops below 30 %.
-
Justify in detail three serious technical problems that this architecture creates when debugging an intermittent failure or performing automated unit tests.
-
Design a modular refactoring of the program: break the function down into at least four independent functions. For each one, define its name, typed input parameters, return value, and its single responsibility.
-
Explain how your design would allow testing the irrigation decision algorithm through data simulation, without having the physical sensors connected to the board.
A group of three students is going to develop an attendance tracking application for the school over ten weeks. To avoid delays and last-minute failed deliveries, you…
A group of three students is going to develop an attendance tracking application 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.