Back to homeTechnology and Engineering I · 1st Bach. Science · Change subject
Start for free
BAC1 tech · Technology and Engineering I
Computer systems · Text-based programming

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.

Before you start, make sure you know: Text-based programming (3rd ESO)
Before you start, make sure you know: Algorithms and computational thinking (2nd ESO)

The development cycle

Flowchart of the development cycle with the stages of editing, running, testing and debugging. Edit the code Run and test does it work properly? Debug the error Release the program no yes
Practice★☆☆Not started
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.

Solve
Practice★☆☆Not 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.

Solve
Practice★☆☆Not started
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.

Edit code Run and test does it work properly? ? Publish program no yes

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.

Solve

Types of error

Comparison between a syntax error and a logic error: with a fault in the form of the code the program stops and does not start; with a fault in the reasoning (dividing by 4 instead of by 3) the program runs and gives 5,25 instead of 7. syntax error does not start media ← (a + b + c / 3 ! logic error starts, wrong result media ← (a + b + c) / 4 5,25 expected: 7
Practice★☆☆Not started
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.

Solve
Practice★★☆Not started
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?

Solve

Designing test cases

Number line with the test cases: an erroneous value outside the range, two boundary values at the ends of the valid range and a normal value inside it. erroneous boundary normal boundary range of valid values
Practice★☆☆Not started
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.

Solve
Practice★★☆Not started
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.

Solve
Practice★★☆Not started
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.

Solve
Practice★★★Not started
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;

}
  1. 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.

  2. Justify, based on this example, the difference between what syntactic verification by the compiler guarantees and what dynamic software testing proves.

  3. Propose the code fix and write a specific test case that demonstrates the bug if the fix were not applied.

Solve
Practice★★★Not started
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.

Solve
Practice★★★Not started
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.

Solve
Practice★★★Not started
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);

}
  1. Predict the function's output for n = 7, n = 0, and n = -7. Explain technically why an unexpected result occurs in one of them based on how the modulo operator (%) handles negative operands in this language.

  2. Fix the expression so that the function is mathematically correct for any integer.

  3. Based on this case, refute the idea of dispensing with unit tests in short or seemingly trivial algorithms using two technical arguments.

Solve

Debugging techniques

Debugging cycle: reproduce the fault, add traces to see where the program goes, fix the cause and test again with the same data. 1. reproducethe fault2. traces: seewhere it goes3. fixthe cause4. test againand remove traces log: loop 1: n = 5 loop 2: n = 5 loop 3: n = 5 … n does not change → «n ← n − 1» is missing inside the loop
Practice★☆☆Not started
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).

Solve
Practice★★☆Not started
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.

Solve
Practice★★★Not started
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.

Solve
Practice★★★Not started
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).

  1. 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.

  2. 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).

  3. 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?

Solve

Modularising, refactoring and documenting

Modularisation diagram: a giant 400-line function is divided into four independent functions: leer_datos, validar_datos, calcular_resultado and mostrar_resultado. giant 400-line function is divided into leer_datos validar_datos calcular_resultado mostrar_resultado each function, one specific task
Practice★☆☆Not started
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.

Solve
Practice★☆☆Not started
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.

Solve
Practice★★☆Not started
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.

Solve
Practice★★☆Not started
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.

Solve
Practice★★☆Not started
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).

Solve
Practice★★☆Not started
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).

Solve
Practice★★★Not started
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 %.

  1. Justify in detail three serious technical problems that this architecture creates when debugging an intermittent failure or performing automated unit tests.

  2. 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.

  3. Explain how your design would allow testing the irrigation decision algorithm through data simulation, without having the physical sensors connected to the board.

Solve
Practice★★★Not started
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:

  1. 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.

  2. 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.

  3. 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.

Solve

Summary

See all the exercises in this section