Unit 3: Design and testing
Software Engineering notes · PTU syllabus (UGCC2514)
On this page
Unit summary
Design turns requirements into a blueprint for code, and testing checks that the code actually works. This unit covers design concepts and quality, software architecture, data design, the main UML diagrams, testing strategies, black-box and white-box testing, debugging, and product metrics.
After this unit you can
- Explain the design process, design concepts and quality attributes
- Draw and explain use case, class, sequence, collaboration and component diagrams
- Apply testing strategies and black-box and white-box techniques
- Use product metrics for analysis, design, code, testing and maintenance
PTU syllabus topics
- Design process and quality
- design concepts and model
- software architecture
- data design
- class/sequence/collaboration/use case/component diagrams
- testing strategies
- black-box and white-box testing
- validation and system testing
- debugging
- product metrics for analysis
- design
- source code
- testing and maintenance
Topic 1
Design process and design concepts
Design quality guidelines: a design should implement all requirements, be readable and understandable, and give a complete picture of data, functions and behaviour.
- Abstraction
- Focus on essentials, hide detail
- Architecture
- Overall structure of components
- Modularity
- Divide software into separately named modules
- Information hiding
- Modules hide internal details
- Functional independence
- High cohesion, low coupling
- Refinement
- Step-wise elaboration of detail
Exam tip
High cohesion (each module does one thing well) and low coupling (modules depend little on each other) is the mark of good design.
Example
Coupling and cohesion: a module that only calculates tax has high cohesion. If it also prints reports and sends email, cohesion is low. Two modules that share global variables are tightly coupled; two that pass only the data needed are loosely coupled.
Exam tip
Aim for high cohesion and low coupling.
Topic 2
Software architecture and data design
Software architecture is the structure of a system: its components, their properties and relationships. Common styles: data-centred, data-flow (pipe and filter), call-and-return, layered, object-oriented and client-server. Data design turns the data model from analysis into data structures and database designs.
Example
Architectural styles: a web shop with browser, application server and database is layered (three-tier). A compiler passing output from one stage to the next is pipe and filter. A banking system where many clients query one server is client–server.
Topic 3
UML diagrams
| Diagram | Shows |
|---|---|
| Use case diagram | Actors and the functions (use cases) they use |
| Class diagram | Classes, attributes, operations and relationships |
| Sequence diagram | Messages between objects in time order |
| Collaboration (communication) diagram | Object interactions, focusing on links |
| Component diagram | Physical software components and their interfaces |
Example
Use case diagram for a library: actors Student and Librarian; use cases Search Book, Issue Book, Return Book, Pay Fine.
Exam tip
In a class diagram, learn the four relationships: association (a line), aggregation (hollow diamond — whole and part can exist separately), composition (filled diamond — part cannot exist without the whole) and generalisation (hollow triangle — inheritance).
Topic 4
Testing strategies and techniques
- 1Unit testing
Individual modules
- 2Integration testing
Modules combined: top-down or bottom-up
- 3Validation testing
Against requirements: alpha and beta
- 4System testing
Recovery, security, stress, performance
Based on
Specifications
Internal code
Techniques
Equivalence partitioning, boundary value analysis
Basis path testing, statement and branch coverage
Done by
Testers, users
Developers
Finds
Missing or wrong functions
Logic and path errors
Cyclomatic complexity V(G) = E − N + 2 (edges − nodes + 2) gives the number of independent paths to test.
Example
Cyclomatic complexity: a flow graph has 9 edges and 7 nodes: V(G) = 9 − 7 + 2 = 4, so there are 4 independent paths and at least 4 test cases are needed. The same program with 3 decision nodes gives V(G) = 3 + 1 = 4 — a shortcut when all decisions are simple conditions.
Example
Boundary value analysis: a field accepts marks from 0 to 100. Test values: −1, 0, 1, 99, 100, 101 — just outside, on, and just inside each boundary. Equivalence partitioning reduces this to three classes (below 0, 0–100, above 100) with one test from each.
Debugging finds and fixes the cause of a failure, using brute force, backtracking or cause elimination.
Topic 5
Product metrics
Metrics measure software quality: analysis model (function points), design model (coupling, cohesion, depth of inheritance), source code (LOC, Halstead metrics), testing (test coverage, defects found) and maintenance (Software Maturity Index).
Example
Cyclomatic complexity: a function has one if and one while. V(G) = number of decisions + 1 = 3, so three independent paths must be tested. From a flow graph with 9 edges and 8 nodes, V(G) = E − N + 2 = 3.
Key terms
- Cohesion
- How closely the functions within a module belong together
- Coupling
- How much modules depend on each other
- Use case
- A sequence of actions giving a result to an actor
- Black-box testing
- Testing based on specifications, not code
- Cyclomatic complexity
- The number of independent paths in a program
Quick revision
- Good design: high cohesion, low coupling.
- UML: use case, class, sequence, collaboration, component.
- Unit → integration → validation → system testing.
- V(G) = E − N + 2.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Differentiate between cohesion and coupling.
- Q2.What is information hiding?
- Q3.What does a sequence diagram show?
- Q4.Differentiate between black-box and white-box testing.
- Q5.What is boundary value analysis?
- Q6.Define cyclomatic complexity.
Long-answer questions
- Q1.Explain the fundamental design concepts in software engineering.
- Q2.Draw a use case diagram and a class diagram for an online shopping system.
- Q3.Explain software testing strategies from unit to system testing.
- Q4.Explain black-box and white-box testing techniques with examples.
Stuck on this unit?
Message SBS on WhatsApp for help with Software Engineering, or to ask about studying BCA at Synetic.
