Module 12 · 17 min read · Free chapter
Software life cycle and testing
The software life cycle runs from feasibility and requirements through design, coding and testing to maintenance. Waterfall suits fixed requirements, prototyping unclear ones and spiral risky ones. Basic COCOMO gives effort E = a(KLOC)ᵇ, cyclomatic complexity is V(G) = E − N + 2P, and testing runs from unit to acceptance level.
Start from zero: why software needs a plan
Think of the railway reservation counter at a busy station. Suppose the railway wants a computer system to replace the paper charts. Nobody would hire ten programmers on Monday and ask them to start typing code by Tuesday.
First someone must ask whether the system is worth building and affordable, which is a feasibility study. Then the clerks, passengers and officers must say what they need, such as booking, cancellation, waiting lists and refunds. Only after that can engineers design the screens and database, write the code, test it and finally keep it running for years.
These steps together form the software development life cycle (SDLC). The usual phases are feasibility study, requirements analysis and specification, design, coding and unit testing, integration and system testing, and maintenance. Software engineering is the discipline of moving through these phases in a planned, measurable way.
Why it matters. Most failed software projects fail because of unclear requirements or poor testing, not because the programmers could not code. That is why RRB JE IT and IT officer papers ask about life cycle models, estimation and testing far more than about any one language.
Life cycle models: waterfall, prototyping, spiral and agile
A life cycle model fixes the order in which the phases happen and how often they repeat. The oldest is the classical waterfall model. Each phase finishes completely, produces a document, and only then hands over to the next phase, like water falling down steps.
The classical waterfall has no way back, which is unrealistic, because mistakes found in testing often trace back to design. The iterative waterfall adds feedback paths to earlier phases. Both work best when the requirements are clear and stable from the start, such as a payroll system with fixed rules.
What if the customer cannot say clearly what they want? Prototyping builds a quick, rough working model, shows it to the users and refines the requirements from their reactions. The prototype is usually thrown away, and the real system is then built properly.
The incremental model delivers the system in parts, so a core version reaches users early and later increments add features. The spiral model goes round in loops, and each loop has four steps: set objectives, analyse and reduce risks, develop and test, and plan the next loop. Because risk analysis drives every loop, the spiral suits large, risky projects, and it can contain the other models inside its loops.
Agile methods go further: they deliver working software every few weeks and keep the customer close throughout. In Scrum, the product owner keeps a prioritised product backlog, the scrum master removes obstacles, and the team works in time-boxed sprints. Each sprint has a short daily scrum meeting, ends with a sprint review of the working product and a retrospective on how the team can improve.
| Model | Best when | Weak point |
|---|---|---|
| Classical waterfall | Requirements are clear and fixed. | Errors found late are costly to fix. |
| Prototyping | Users cannot state requirements clearly. | The thrown-away prototype adds cost. |
| Incremental | An early core version is useful. | The overall design must be planned well. |
| Spiral | The project is large and risky. | It needs skilled risk analysis. |
| Agile (Scrum) | Requirements keep changing. | Documentation and long-term planning can be thin. |
Why it matters. Exam questions usually describe a situation and ask which model fits. If the clue is "unclear requirements", answer prototyping; if it is "high risk", answer spiral; and if it is "frequent change with short deliveries", answer agile.
Requirements, SRS, cohesion and coupling
The requirements phase ends with the software requirements specification (SRS). The SRS states what the system must do, and it deliberately avoids saying how it will be coded. A booking system's SRS might say "the system shall show the waiting-list position within 2 seconds", but it would not name the sorting routine.
Requirements are of two kinds. Functional requirements are services, such as "book a ticket" or "print a refund slip". Non-functional requirements are qualities, such as response time, security, reliability and ease of use.
A good SRS is correct, unambiguous (one meaning only), complete, consistent (no two requirements clash), verifiable (each can be tested) and traceable (each can be followed into design and tests). A line like "the system should be fast" fails the verifiable test, because nobody can check it.
Next comes design, where the system is split into modules. Two measures judge a split. Cohesion asks how closely the parts inside one module belong together, and coupling asks how much one module depends on another.
From worst to best, cohesion is coincidental (unrelated tasks thrown together), logical (similar kinds of tasks, such as all input routines), temporal (tasks done at the same time, such as start-up), procedural (steps of one procedure), communicational (tasks on the same data), sequential (output of one is input to the next) and functional (everything does one single job). From worst to best, coupling is content (one module changes another's internals), common (shared global data), external, control (passing a flag that steers the other module), stamp (passing a whole structure) and data (passing only the needed values).
Why it matters. "High cohesion, low coupling" is the one-line rule of good design, and it is asked almost every year in IT officer papers. A module with functional cohesion and data coupling can be changed, tested and reused on its own.
Estimation: function points and basic COCOMO
Before a contract is signed, the manager must estimate size, effort and time. Size can be counted in lines of code (KLOC, thousands of lines), but lines are known only after coding. Function points measure size from the requirements instead, by counting what the system does for the user.
Five components are counted: external inputs (EI, such as a booking form), external outputs (EO, such as a printed ticket), external inquiries (EQ, such as a PNR status query), internal logical files (ILF, data the system keeps) and external interface files (EIF, data read from other systems). Each count is multiplied by a weight, whose average values are 4, 5, 4, 10 and 7. Then fourteen general system characteristics, such as performance and online data entry, are each rated from 0 to 5.
Since each lies between 0 and 5, the sum lies between 0 and 70, so lies between 0.65 and 1.35. In other words, the adjustment can move the count down by 35% or up by 35%.
Worked example 1. A system has 20 EI, 30 EO, 10 EQ, 8 ILF and 2 EIF, all of average complexity, and its fourteen ratings add up to 42. Then . Next , so .
Basic COCOMO turns size in KLOC into effort and time. Projects are organic (small team, familiar problem), semi-detached (medium, mixed experience) or embedded (tight hardware or rules, such as railway signalling).
| Project type | a | b | c | d |
|---|---|---|---|---|
| Organic | 2.4 | 1.05 | 2.5 | 0.38 |
| Semi-detached | 3.0 | 1.12 | 2.5 | 0.35 |
| Embedded | 3.6 | 1.20 | 2.5 | 0.32 |
Worked example 2. An organic project is estimated at 32 KLOC. Effort is person-months, and time is months. The average team size is , so about seven people are needed.
Worked example 3. If the same 32 KLOC were an embedded project, then , so person-months. The effort is about two and a half times that of the organic case for the same size.
Why it matters. Because , effort grows faster than size: doubling the code more than doubles the work, since communication between more people costs time. Exams test this idea and also test whether you can carry out the power calculation correctly.
Cyclomatic complexity: counting independent paths
How many tests are needed to exercise every decision in a function? Draw its control flow graph (CFG): each node is a block of statements that run together, and each edge is a possible jump. The cyclomatic complexity counts the independent paths through this graph.
Here is the number of edges, the number of nodes and the number of connected components, which is 1 for a single function. For a single program whose decisions are all two-way, two other counts give the same answer: the number of decision points plus 1, and the number of regions of the planar graph, counting the outside region.
Take a function that finds the maximum of an array.
max = a[0]; i = 1; /* node 1 */
while (i < n) { /* node 2 */
if (a[i] > max) /* node 3 */
max = a[i]; /* node 4 */
i++; /* node 5 */
}
return max; /* node 6 */
Worked example 1. The edges are 1→2, 2→3, 2→6, 3→4, 3→5, 4→5 and 5→2, so and . Then . There are two decisions, the while test and the if test, so the second method also gives .
The three independent (basis) paths are 1-2-6 (the loop never runs), 1-2-3-5-2-6 (no new maximum) and 1-2-3-4-5-2-6 (a new maximum). So at least three test cases are needed to cover the basis paths, for example , an array whose first element is largest, and an array whose last element is largest.
Worked example 2. A program's CFG has 10 nodes and 13 edges in one component. Then , so it has five independent paths. If the program were instead split into two separate components with 16 edges and 14 nodes in total, .
Why it matters. gives both a measure of how hard a function is to understand and a lower bound on the number of white box test cases for basis path coverage. Many teams treat a value above about 10 as a sign that a function should be split.
Testing: levels, black box and white box, verification and validation
Testing runs the software on chosen inputs to find failures, and a failure points to a fault (bug) in the code. Testing happens at four levels. Unit testing checks one module alone, integration testing checks modules working together, system testing checks the whole system against the SRS, and acceptance testing lets the customer decide whether to accept it.
Integration can be big bang (everything at once), top-down (upper modules first, with stubs standing in for missing lower modules), bottom-up (lower modules first, with drivers calling them) or sandwich (both together). Acceptance testing by users at the developer's site is alpha testing, and at the users' own sites it is beta testing. After any change, regression testing re-runs old tests to make sure nothing that worked before is now broken.
Black box testing treats the program as a closed box and designs tests from the specification only. Equivalence class partitioning splits the input range into classes that the program should treat alike, and picks one value from each. Boundary value analysis then adds values at and next to each edge, because bugs gather at boundaries, such as < written instead of <=.
Worked example. A form accepts ages from 18 to 60. The equivalence classes are below 18 (invalid), 18 to 60 (valid) and above 60 (invalid), so three tests such as 10, 35 and 70 cover them. Boundary value analysis adds 17, 18, 19, 59, 60 and 61. For independent inputs, basic boundary value analysis takes min, min+1, max−1 and max of one input while the others stay at nominal values, plus one all-nominal case, giving tests, so two inputs need .
White box testing looks inside the code. Statement coverage needs every statement run at least once, branch coverage needs every branch outcome (true and false) taken, and path coverage needs every path, which is the strongest and often impossible with loops. For if (x > 0) y = 1;, the single test gives full statement coverage but only half the branches, because the false outcome is never tried.
Finally, two words are often mixed up. Verification asks "are we building the product right?" and checks each phase's output against its input, often by reviews, walkthroughs and inspections. Validation asks "are we building the right product?" and checks the finished software against what the user actually needs.
Why it matters. Testing can show the presence of bugs but never prove their absence, so test design is about choosing the few inputs most likely to break the program. Questions on boundary values, coverage and stubs against drivers are easy marks once the ideas are clear.
Maintenance and version control
Software is not finished on the day it is delivered. Over its life, most of the total cost usually goes into maintenance, which is of four types. Corrective maintenance fixes bugs that users report, and adaptive maintenance changes the software for a new environment, such as a new operating system, a new tax rule or a new payment gateway.
Perfective maintenance adds features or improves performance because users ask for more. Preventive maintenance restructures and documents the code so that future changes are easier and fewer bugs appear. For example, updating a booking system for a new fare rule is adaptive, while adding a Hindi screen that users asked for is perfective.
Many people change the same code over many years, so a team needs a version control system. It stores every saved snapshot, called a commit, in a repository, with the author, the time and a message. Developers work on separate branches and later merge them, and anyone can go back to an earlier version when a change goes wrong.
In a centralised system, one server holds the history and developers check files out from it. In a distributed system such as Git, every developer's copy holds the full history, so work can continue offline and the server is not a single point of failure.
Why it matters. Maintenance questions usually give a situation and ask for its type, so learn one example of each. Version control is the everyday tool that makes team development, code review and safe rollback possible.
Descriptive lens: how written papers ask this
GATE does not test this chapter, but written papers for IT officer posts, state Assistant Programmer exams and university tests ask about it in four ways:
- Compare life cycle models and choose one for a described project, with reasons.
- Explain design quality through cohesion and coupling, with an example of each level.
- Calculate function points, COCOMO effort and time, or the cyclomatic complexity of a given code fragment.
- Design tests for a given specification using equivalence classes and boundary values, and compare black box with white box testing.
Practice questions (our own, not previous-year questions).
- Compare the waterfall, prototyping and spiral models. Which would you choose for a new state-wide land records system whose requirements are only partly known, and why? (15 marks)
- Draw the control flow graph of a function that counts the even numbers in an array, find its cyclomatic complexity by two methods, and list its basis paths. (10 marks)
- Explain cohesion and coupling. Why does good design aim for high cohesion and low coupling? (10 marks)
Answer plan for question 1.
- Begin by defining a life cycle model as the order and repetition of the development phases.
- Describe the waterfall model as strictly sequential and say that it suits stable, well-known requirements.
- Describe prototyping as a quick model shown to users and explain that it settles unclear requirements before full development.
- Describe the spiral model as loops of objectives, risk analysis, development and planning, and note that it handles large and risky projects.
- Conclude that a land records system with partly known requirements and high public risk fits the spiral model, with prototyping used inside its early loops for the screens.
Quick revision
- The SDLC runs through feasibility, requirements, design, coding and unit testing, integration and system testing, and maintenance.
- Waterfall suits fixed requirements, prototyping suits unclear ones, the spiral model is risk-driven, and agile delivers in short sprints.
- An SRS says what the system must do, and it holds functional and non-functional requirements.
- Cohesion runs from coincidental (worst) to functional (best), and coupling runs from content (worst) to data (best).
- Function points are , where lies between 0.65 and 1.35.
- Basic COCOMO gives and , and organic projects use and .
- Cyclomatic complexity is , which equals decisions plus 1 for one program.
- Basic boundary value analysis needs tests for inputs.
- Branch coverage implies statement coverage, and path coverage is the strongest.
- Verification checks that the product is built right, and validation checks that the right product is built.
- Maintenance is corrective, adaptive, perfective or preventive.