0% found this document useful (0 votes)
24 views

Foundations of Programming

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Foundations of Programming

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 220

Module 1.

Introduction to Software Development

Software development is at the heart of the digital solutions that shape our lives.
From mobile applications to business systems, understanding the processes that
turn ideas into functional software is important for anyone interested in IT or wanting
to understand our digital world better.

In this module, "Introduction to Software Development," you will explore:

● Learn what programming is, its history, and its role in software
development.
● Discover the Software Development Lifecycle's (SDLC) nature, the
blueprint of software creation, and how concepts evolve into products.
● Gain insights into the importance of user requirements in software
development and how to translate user needs into functional
specifications.

To enhance your understanding, we have tailored specific learning activities:

● Reflect on your interactions with software and applications and their


importance in daily life.
● Design a flowchart for a hypothetical project, exploring the various stages
of software creation.
● Experience a simulated client meeting to gather requirements for a small
software project.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 1: Acquire a thorough understanding of the various stages and


decision points in the SDLC, including capturing user requirements and
specifications.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Introduction to Programming and Software


Development

Key takeaways from this topic...

1. Learn the fundamental concepts and terminologies used in programming and


software development.
2. Understand the critical role of programming in the broader spectrum of
software development, which encompasses a range of activities from design
to deployment.
3. Gain an insight into the different programming languages and tools that are
commonly used in the industry.
Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Section 1: The Core of Digital Revolution

source: freepik

Links to an external site.

The Digital Revolution and the Role of Programming

At the heart of today’s digital revolution lies the science of programming. From the
alarm that wakes you up to global stock exchanges, every aspect of modern life is
infused with coded software. If you’ve ever wondered how your favourite applications
or websites function or thought about the engine under the vast expanse of digital
services, then you’re thinking about programming.

Breaking Down ‘Programming'

Programming is the act of instructing computers to perform specific tasks. At its core,
it’s a series of commands given to a computer to process information in a specific
way. To understand this, imagine a chef following a recipe. Each step in that recipe
corresponds to an instruction, and the entire dish represents the final program.

Section 2: The Necessity of Programming

source: freepik

Links to an external site.

Why Do We Need Programming?

Computers, without instructions, are vast reservoirs of potential, waiting for direction.
By themselves, they can’t make decisions, nor can they perform tasks. They need
precise, step-by-step guidance.

Here’s where programming enters the scene. Among a multitude of purposes, it


allows us to:
1. Automate Repetitive Tasks
Think about large-scale data sorting or calculations – programming makes
these possible in mere seconds.
2. Craft Digital Solutions
From creating interactive websites to simulating real-world processes,
programming provides the tools.
3. Create tailored experiences
Playlists on music streaming services or recommended videos on platforms
are powered by algorithms, which are born from programming.

Further Reading

Why Is Computer Programming Important?

Links to an external site.

Explore how computer programming is like the lifeblood of modern society. Learning
to program is like gaining a superpower that extends beyond creating software—it's
the key to simplifying banking processes, ensuring smooth supply chains, and
crafting the amazing online experiences we all love.

Reference: Mooc Blog Team 2022, Why Is Computer Programming Important?, MOOC Org (blog),
accessed 18 January 2023, <https://www.mooc.org/blog/why-is-computer-programming-important>

Section 3: Delving Deeper into Software Development and Programming


source: freepik

Links to an external site.

The Multi-faceted World of Software Development

While programming is about writing code, software development is the wider process
of conceptualising, designing, testing, and maintaining applications, frameworks, or
systems. It’s not just about writing code but understanding the problem, knowing the
user, and ensuring that the software evolves as needs change.

A Glimpse into Programming Languages

Just as there are multiple languages to communicate with humans, there are a
myriad of programming languages to communicate with computers. Some popular
ones include:

● Python: Known for its simplicity, it’s a favourite for beginners and is widely
used in data science.
● Java: Versatile and object-oriented, it powers many enterprise-level
applications and Android apps.
● C++: An extension of C, this language is known for performance-critical
applications.

Each language has its strengths, and the choice often depends on the problem at
hand.

The Life of a Software Developer

A day in the life of a software developer is diverse. While they do spend significant
time writing and refining code, they also:
● Brainstorm Ideas
Before any code is written there are sessions to define what needs to be
built.
● Debug
This is the process of finding and resolving defects or problems within the
program that prevent correct operation of computer software or a system.
● Collaborate
Developers often work in teams, collaborating with designers, testers, and
other specialists.
● Continuous Learning
The tech world is ever-evolving. Developers often find themselves learning
new languages or techniques.

Further Reading

Day in the Life of a Software Engineer

Links to an external site.

Software engineers are the backbone of websites and applications we use every
day, but what’s going on behind the curtain? What does a day in the life of a software
engineer actually look like? Explore the tasks they work on to the people they talk to,
the tools they use, and what they think makes them successful.

Reference: Zoe Kaplan 2023, Day in the Life of a Software Engineer, Forage Blog, accessed 30
January 2024, <https://www.theforage.com/blog/careers/day-in-life-software-engineer>

Topic 2. Software Development Lifecycle

Key takeaways from this topic...


1. Understand the SDLC as a framework that outlines the stages involved in the
development of software, helping to ensure successful project outcomes.
2. Learn the key stages of the SDLC, including requirement analysis, design,
implementation, testing, deployment, and maintenance.
3. Develop an appreciation for the importance of each stage in the SDLC,
understanding how they contribute to the development of reliable and efficient
software.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding the Software Development Lifecycle (SDLC)


source: freepik

Links to an external site.

The Software Development Lifecycle: A Blueprint for Success

At the core of any successful software project is a well-defined Software


Development Lifecycle (SDLC). Just like constructing a building requires a blueprint,
creating a robust software application demands a structured approach. The SDLC
serves as this guidebook, outlining each phase that a software project will go through
from inception to deployment and maintenance.

What Is the Software Development Lifecycle?

In essence, the SDLC is a framework that guides the process of developing a


software application or system. Think of it as the roadmap or the “recipe” for software
development. It lays out the stages, activities, and tasks needed to convert an idea
into a functional piece of software.

Section 2: Phases of SDLC


source: freepik

Links to an external site.

The Critical Phases of SDLC

The Software Development Lifecycle is generally divided into the following phases:

1. Requirement Analysis
This is the “listening” phase. Developers and stakeholders identify the needs,
constraints, and functionality desired in the software.

2. System Design
Based on the requirements gathered, a blueprint for the software system is
designed. This will guide the team through the development process.

3. Implementation
This is where the real action takes place. Developers write code based on the
design blueprint, turning theory into practice.

4. Testing
Before releasing the software into the wild, it’s tested rigorously to identify
bugs, errors, and areas for improvement.

5. Deployment
Once the software passes all tests, it’s launched and made available to users.

6. Maintenance
Software is never really ‘complete.’ It requires continuous updates,
improvements, and bug-fixes.

Why Does SDLC Matter?

Understanding the SDLC is vital for several reasons:

● Efficiency and Productivity


A structured approach saves time and resources. It’s akin to having a
well-planned grocery list before shopping.

● Quality Assurance
Following a lifecycle ensures each step is rigorously examined and
fine-tuned, resulting in a higher-quality end product.
● Risk Management
SDLC allows developers and stakeholders to identify potential pitfalls or
bottlenecks early in the process, avoiding costly issues down the line.

Further Reading

Software Development Life Cycle (SDLC)

Links to an external site.

SDLC is a structured process that is used to design, develop, and test good-quality
software. It is a methodology that defines the entire procedure of software
development step-by-step. Explore further each stage of the process.

Reference: Geeks for Geeks (n.d.), Software Development Life Cycle (SDLC), Geeks for Geeks,
accessed 30 January 2024, <https://www.geeksforgeeks.org/software-development-life-cycle-sdlc/>

Section 3: Application and Methodologies of SDLC


source: freepik

Links to an external site.

Example: Developing a Food Delivery Mobile Application

Requirement Analysis Phase:

● Identify user needs and preferences for food delivery.


● Define features like order placement, payment options, and real-time
tracking.

System Design Phase:

● Create visual wireframes and mockups of the app’s interface.


● Plan the app’s architecture for data storage and processing.

Implementation Phase:

● Write code to turn design into functional features.


● Develop user registration, order placement, payment processing, and
location tracking.

Testing Phase:

● Test components, integration, and user acceptance.


● Identify and fix bugs, errors, and performance issues.

Deployment Phase:

● Publish the app on app stores for users to download.


● Enable users to place orders and track deliveries.

Maintenance Phase:

● Continuously update the app based on user feedback.


● Fix bugs, enhance performance, and add new features.

Agile, Waterfall, and More: The Methodologies


SDLC can be implemented using various methodologies like Agile, Waterfall, or
Scrum. Each comes with its pros and cons:

● Agile: Favours flexibility and is excellent for projects where user


requirements may evolve.
● Waterfall: Sequential and straightforward, but less flexible.
● Scrum: A subset of Agile, focusing on teamwork and iterative progress.

Summary

The SDLC serves as a critical blueprint that guides developers in orchestrating a


successful software project from inception to deployment and maintenance. It
ensures a structured, systematic approach to converting a concept into a tangible,
functional software application, promoting efficiency, quality assurance, and effective
risk management throughout the development process.

Topic 3. Understanding User Requirements and


Specifications

Key takeaways from this topic...

1. Learn the importance of accurately capturing user requirements and


specifications, which forms the basis of any software development project.
2. Develop skills in communicating with clients and stakeholders to gather
requirements effectively.
3. Understand how to translate user requirements into technical specifications,
which guides the development process and helps in meeting user
expectations.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: The Foundation of Software Development - Understanding User


Requirements

Understanding Requirements and Specifications

In the development of any software, comprehending the requirements and


specifications stands as a foundational step. Liaising with stakeholders at this phase
helps grasp what they envision the software to accomplish. The information collected
here is a blueprint for the development process, outlining what needs to be built and
how it will satisfy the users’ needs. In this guide, we shall walk through the essential
aspects of understanding user requirements and specifications, infused with a
practical case study to give you a holistic view of the process.
The Importance of User Requirements

Before diving into strategies of collecting user requirements, let’s explore why it is
crucial in software development:

● Guiding Development
Offers clear guidelines for the development team on what needs to be
created.
● Budget and Timeline Planning
Helps in devising realistic budgets and timelines.
● Minimising Miscommunication
Reduces chances of misunderstandings between stakeholders and
development teams.

Further Reading

Functional and Nonfunctional Requirements: Specification and Types

Links to an external site.

Clearly defined requirements are essential signs on the road to a successful project.
They establish a formal agreement between clients and providers that they are both
working to reach the same goal. Explore the different types of requirements you may
need to consider, and learn to differentiate between those that are functional and
non-functional.
Reference: Altexsoft staff 2023, 'Functional and Nonfunctional Requirements: Specification and
Types', Altexsoft blog, accessed 30 January 2024,
<https://www.altexsoft.com/blog/functional-and-non-functional-requirements-specification-and-types/>

Section 2: Strategies for Effective Requirement Gathering

Strategies for Gathering Requirements

Understanding user requirements is a pivotal stage in the development of any


software product or system. It involves gathering insights into what end-users expect
from the software, facilitating the creation of a system that meets their needs and
expectations. This section explores various strategies extensively used in the
industry, complemented by practical examples to help you grasp the essence of
each strategy:

● Stakeholder Interviews
Conducting one-on-one interviews with stakeholders, including potential
users, to understand their expectations, needs, and challenges with the
current system.
● Surveys and Questionnaires
Utilising these tools to collect data from a larger group of potential users,
gathering both quantitative and qualitative data.
● Observational Studies
Observing users interacting with the current system to identify pain points
and areas for improvement.
● Focus Groups
Generating a deeper understanding of user attitudes, perceptions, and
desires regarding the product through moderated discussions.
● Use Case Development
Creating specific scenarios that illustrate how users will interact with the
new system, identifying any gaps or areas for improvement early in
development.

Learn more in the 6-step guide to requirements gathering

Links to an external site.

from Team Asana (2022)

Modelling the Requirements

The Role of Flow Charts

Flow charts are used to model the flow of activities/events identified in a system.
Once requirements are captured, Flowcharts can be created to model the
process/logic of client requirements.

The Role of Pseudocode


Pseudocode is a high-level description of a computer algorithm that uses plain
language to outline the logic and steps of the solution in a way that is independent of
programming language syntax. It is a useful tool for designing and planning code by
focusing on the algorithm's structure and flow rather than specific code details.

Pseudocode is used to model the algorithms identified in a system. Once


requirements are captured, Pseudocode can be written, to model the logic of client
requirements.

Section 3: Case Study

In a metropolitan area bustling with life, the central city library, a revered institution,
found that its manual book management system was increasingly unable to keep up
with the volume of visitors and the diversity of its book collection. In an effort to
modernise and streamline their operations, the library authorities decided to
transition to a digital library management system. The envisioned system would not
only expedite the lending process but would also offer an enriched user experience,
encouraging more individuals to utilise the library’s resources.

Preparatory Phase

Before embarking on the development journey, the project team, consisting of


software engineers, UI/UX designers, and library management experts, initiated a
series of meetings to brainstorm and lay down the preliminary plan. The team
recognised the necessity of a deep understanding of both the library’s operational
nuances and the users’ preferences and challenges.

Strategies Implemented
To fully grasp the user requirements, the project team adopted a multi-faceted
approach:

● Stakeholder Interviews
The team conducted in-depth interviews with a diverse group comprising
librarians, frequent library visitors, and even individuals who rarely visited
the library. This exercise helped in garnering a rich perspective on the
different expectations and potential improvements that could be
incorporated into the new system.
● Surveys and Feedback
In parallel, an online survey was rolled out, aimed at collecting quantitative
data regarding user preferences, issues faced with the current system,
and suggestions for the new system.
● Observational Studies
The team spent several days observing the day-to-day operations in the
library, noting the bottlenecks in the existing system and identifying areas
where technology could bring in efficiency and precision.
● Use Case Development
Based on the collected data, the team developed comprehensive use
cases, illustrating the different ways the proposed system would interact
with the users and other systems.

Development Phase

With a clear vision, the development phase kicked off, guided by the detailed user
requirements and specifications document crafted in the preparatory phase. A
modular approach was adopted, which facilitated a flexible and adaptive
development process.

User Testing and Adjustments


Once a prototype was ready, it was introduced to a select group of users and
librarians for testing. Their feedback became instrumental in making necessary
adjustments, ensuring the system was finely tuned to meet the user’s needs.

Outcome

The culmination of meticulous planning and user-centric development resulted in a


library management system that was intuitive, efficient, and comprehensive. The
system drastically reduced the time required for lending processes, and the library
users found the search and reservation features particularly impressive.

The librarians appreciated the automated notifications and reminders, which made
managing book returns more manageable. Moreover, the new system introduced a
recommendation feature, suggesting books based on users’ reading histories, which
was well-received, fostering a vibrant reading community within the library.

Further Resources

The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: The Digital Revolution - How Computers Are Rewriting the Story of
Humanity
This article invites readers on an exciting journey to understand the digital
revolution's core, where computers play a vital role in our fast-changing technology
world. Starting from the bulky computers in the 1950s to today's sleek and powerful
machines, the article explores how these incredible inventions have changed the
way we live, work, and have fun.
The Digital Revolution: How Computers Are Rewriting the Story of Humanity

Links to an external site.

Reference: ArtFex 2023, The Digital Revolution: How Computers Are Rewriting the Story of Humanity,
Medium (Blog), accessed 18 January 2023,
<https://medium.com/@artfex.info/the-digital-revolution-how-computers-are-rewriting-the-story-of-hum
anity-d2cbe23c4647>

Reading: Types of Requirements in Software Engineering


This article discusses requirements in three main categories: business, user, and
software. It provides examples of each category and explains the differences
between functional and non-functional software requirements. Learn about the
various types of requirements and how they contribute to the development of
software.

What are the Types of Requirements in Software Engineering?

Links to an external site.

Reference: Bigelow S. J 2020, What are the types of requirements in software engineering?,
TechTarget (website), accessed 18 January 2024,
<https://www.techtarget.com/searchsoftwarequality/answer/What-are-requirements-types>

Programming Resources
The resources in this section will help prepare you to get started with programming in
C++ – the language we will be using in this subject.

Expand All
Panels
Collapse All
Panels
Video: Should you Learn C++?
This video discusses the modern relevancy and context of C++, emphasising that it
is a language used for writing highly efficient and fast-running code, particularly in
areas such as embedded systems, game engines, and AI engines. The key
advantage of C++ is its ability to provide fast runtime due to its lower-level code,
closer to the CPU.

youtu.be/D7cCdzS4cXQ

Links to an external site.

(07:27)

Reference: Stefan Mischook 2023, Should you Learn C++ in 2023?, YouTube, accessed 30 January
2024, <https://youtu.be/D7cCdzS4cXQ>

Video: Learning C++


In this LinkedIn Learning course, learn the basic elements of C++. Instructor
Eduardo Corpeño begins with setting up the development environment and
introducing the basic elements of object-oriented programming.

Watch only the 'Getting Started' section (approx. 20mins).

Learning C++

Links to an external site.

Reference: Eduardo Corpeño 2021, 'Learning C++', LinkedIn Learning, accessed 18 January 2023,
<https://www.linkedin.com/learning/learning-c-plus-plus-14267389/setting-up-the-development-enviro
nment-14230629>

Video: C++ Essential Training


In this LinkedIn Learning course, Instructor Bill Weinman discusses the history of
C++ and modern C++, as well as explaining the C++ toolchain. He then dives into
the basics you need to know, like basic syntax, statements and expressions,
identifiers, variables, pointers, and references.

Watch only the Introduction and 'Section 2 - The Basics' (approx. 40mins)

C++ The Basics


Links to an external site.

Reference: Bill Weinman 2022, 'Section 2: The Basics', C++ Essential Training, LinkedIn Learning,
accessed 30 January 2024,
<https://www.linkedin.com/learning/c-plus-plus-essential-training-15106801/basic-syntax>
Module 2. Introduction to Programming
In this module, you will take the first steps on your journey to becoming an amazing
computer programmer by learning how you can instruct a computer to perform
interesting actions and solve complex problems that would take human minds years
to solve.

During the lectures, you are going to learn how to create a set of instructions that a
computer will execute, a program. You will learn how to speak the language of
computers by using programming languages. Also, you will learn how data is used to
store information that your programs can use to solve problems, and how operators
are used to transform (change) your data. Further, you will learn about user-defined
datatypes such as Structures, Unions and Enumerations.

In this module, you will explore:

● Learn what data data types are, their importance, and their application in
programming.
● Discover the functionality and structure of operators, and their importance,
and their application in programming.
● Gain insights into constants and literals, understanding how to create and
use them
● Learn user defined datatypes/structures such as: Structures, Unions and
Enumerations

To enhance your understanding, we have tailored specific learning activities:

● Write a program to store the details of a student.


● Write a program to add numbers using arithmetic operators.
● Write a program to print a greeting using literals and variables.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 2: Gain the ability to create and modify basic data structures such as
arrays and linked lists, along with performing operations like insertion,
deletion, and traversal.
Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Data Types and Variables

Key takeaways from this topic...

1. In C++, data types are classified into primitive types (such as integers,
characters, and floating points) and abstract types, which are user-defined.
2. Variables in C++ store data and are declared with a specific data type; their
names must follow naming conventions and are used to manage data in
memory.
3. C++ uses cout for output and cin for input, with stream operators (<< and
>>) to handle data display and retrieval.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Data Types

In the world of data you are going to learn that


not all data is the same. Data has different types. One type is an integer, a whole
number such as 0, -12, 3, 42, and 1337. Another type is a float, a real number such
as 3.14159265, and 0.76.
This module introduces you to the fundamental data types of C++, including
Integers, characters, and more. You will learn how to modify data types to be able to
have different ranges of values, by using data type modifiers. You will then learn how
to store data that your program can access, via using variables. Variables are a way
of associating a name and a data type that your program can use to make decisions.

A data type is a classification of data that tells the compiler or interpreter how the
programmer intends to use the data.

Data Types in C++

These are mainly divided into two types:

● Primitive Data Types


These are predefined or built-in data types and can be used directly by the
programmer to declare variables. The following are the basic data types
we could use:
○ Integer
○ Character
○ Boolean
○ Floating point
○ Double floating point
● Abstract or user-defined data type
These data types are defined by the user.

Primitive Data Types

● Integer (int): Used for storing whole numbers (100, 20, 4, and so on...).
● Character (char): Used for storing a single character (4, b, $, and so
on...).
● Boolean (bool): Used for storing boolean or logical values (true or false).
Represented in memory as 1 for true and 0 for false.
● Floating point (float): Used for storing values with a decimal point
(3.1415927). Can have up to 7 decimal places.
● Double floating point (double): Used for storing values with a decimal
point (3.141592653589794). Can have up to 15 decimal places.

Data type modifiers

Data type modifiers are used with primitive data types to modify the length of data
that a particular data type can hold. Data type modifiers available in C++ are:

● Signed
● Unsigned
● Short
● Long
● Signed, unsigned, long and short modifiers can be used for int.
● Signed and unsigned can be used for char.
● Long can be used for double.

Section 2: Variables

Variables are used to store information that can be referenced and manipulated by a
computer program. It is called a variable because we can change the value stored. It
is a way of labelling data with a descriptive name, so our program is easier to
understand.

Variables are like containers that hold information. The purpose of them is to label
and store data in computer memory (RAM). Different types of variables require
different amounts of memory, and have a specific set of operations that can be
applied to them. Imagine a large warehouse with lots of storage bays, tables,
shelves, rooms etc. We can store different types of items in each of these places.

Variable data type


C++ is a strongly-typed programming language, so it requires every variable to be
declared with its type before its first use. A typical variable declaration and
initialisation is of this form:

data_type name = value;

A variable has a valid C++ data type, like the primitive data types we just saw.
Examples are:

○ int: number = 3;
○ float: value = -23.45;
○ bool: finished = false;
○ char: letter = ‘a’;

Variable naming

A variable has a name that can consist of:

○ Alphabets (both upper and lower case), numbers and the


underscore ‘_’ character.
○ The name is needed to uniquely identify and reference a
variable, to assign a value to the variable (e.g. radius = 3.2).

It can also be used to retrieve the value stored (e.g., circumference = 2* PI * radius).

A name cannot begin with a number, and there are some defined naming
conventions for C++ variables, but there is no particular standard naming
convention, so you should use the naming convention designated by your company
or team.

Scope of a Variable
There are two different types of variables based on the scope.

○ Global Variable
○ Local Variable

The scope of a variable is determined by where in the program it is declared.

Section 3: Input and Output

Output (cout <<)

Output in C++ is done via cout and the stream insertion operator << chains items.

cout << "Hello " << "world!" << endl;

In the above example, the endl can be used to produce a new line. Whenever an
endl is printed, the cursor moves to the beginning of the next line without any visible
output.

A string is enclosed by a pair of double quotes (“any_text”), and will be printed as it


is, including punctuation marks within the double quotes.

We can also use \n, which denotes a newline character just like endl. Similarly, you
could use \t which denotes tab character, to move the cursor to the next tab position.

cout << "hello world, again!\n";

cout << "\thello,\none\tmore\ttime.\n";


Input (cin >>)

Input in C++ is done via cin and the stream extraction operator >> reads input from
the keyboard and stores the value into a variable.

#include <iostream>

using namespace std;

int main()

// creating a float variable with a default value

float studentMark = 100.0f;

// get input from the user to change the student's mark

cin >> studentMark; // user gives a value of 65.2

// print out the student's mark on the screen

cout << studentMark << endl; // Output: 65.2

Topic 2. Operators

Key takeaways from this topic...

1. Arithmetic Operators are for performing mathematical operations on numbers.


2. Relational Operators are for comparing values and determining their
relationships.
3. Logical operators are used to combine and evaluate boolean expressions for
decision-making.
4. C++ uses assignment operators to assign values to variables and modify their
contents.
5. Increment and Decrement Operators increase or decrease the value of a
variable by one.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Operators

An operator in a programming language tells a compiler to perform specific


mathematical and logical computations on operands.

In the following example, ‘+’ is the addition operator and the variables numOne
and numTwo are operands. The addition operator tells the compiler to add both
numOne and numTwo.

#include <iostream>

using namespace std;


int main()

int numOne = 10;

int numTwo = 20;

int result = 0;

result = numOne + numTwo;

C++ has many built-in operators and they can be classified as:

● Arithmetic operators
● Relational operators
● Logical Operators
● Assignment operators
● Increment and Decrement operators
● Bitwise operators
● Special operators

Arithmetic Operators

Symbol Usage Explanation


+ x+y Adds two operands (x and y)

- x-y Subtracts the second operand (y) from the first operand
(x)

* x*y Multiplies both the operands (x and y)

/ x/y Divides first operand (x) by the second operand (y)

% x%y The modulus operator divides the first operand (x) by the
second operand (y) and returns the remainder.

Assignment Operators

Are used to assign values to a variable.

Symbol Usage Explanation


= x=y Assigns the value from the y to x.

+= x += y Adds the value of y to the value of x and assigns the result


to x.

-= x -= y Subtracts the value of y from the value of x and assigns


the result to x.

*= x *= y Multiplies the value of y to the value of x and assigns the


result to x.

/= x /= y Divides the value of x with the value of y and assigns the


result to x.

%= x %= y Divides the value of x by the value of y and returns the


remainder, the remainder is assigned to x.

Increment / Decrement Operators

Are unary operators that require only one operand.


Symbol Usage Explanation

++ x++ Post-increment, increases the value of the operand (x) by


1 after using its value.

++x Pre-increment, increases the value of the operand (x) by 1


before using its value.

-- x-- Post-decrement, decreases the value of the operand (x)


by 1 after using its value.

--x Pre-decrement, decreases the value of the operand (x) by


1 before using its value.

Relational Operators

Are used for comparing two operands, the result of a relational operator is a boolean
value that is either true or false.
Symbol Usage Explanation

< x<y Checks if the value of x is less than the value of y.

<= x <= y Checks if the value of x is less than or equal to the value
of y.

> x>y Checks if the value of x is greater than the value of y

>= x >= y Checks if the value of x is greater than or equal to the


value of y.

== x == y Checks if the value of x is equal to the value y.

!= x != y Checks if the value of x is not equal to the value of y.

Logical Operators
These take boolean values as input and return boolean values as output. Here, the x
and y are boolean values.

Symbol Usage Explanation

&& x && y Logical AND, returns true when both conditions are
satisfied. Otherwise, it returns false.

|| x || y Logical OR, returns true when one (or both) of the


conditions is satisfied. Otherwise, it returns false if both
the conditions are not satisfied.

! !x Logical NOT, returns true if the condition is not satisfied,


and returns false if the condition is satisfied.

!y

Rule of Precedence and Associativity

The precedence of an operator decreases from top to bottom.


Operator Description Associati
s vity

() Parentheses L -> R

*, /, % Multiplication, Division & Modulus

+, - Addition and Subtraction

<, <=, >, >= Less than, Less than equal to, greater than, greater than
equal to

=, +=, -= Assignment, compound assignment by sum and difference R -> L

Further Reading: A list of all C++ operators

Links to an external site.

shows the precedence and associativity.


Topic 3. Constants, Literals, and User-Defined Data
Types/Structures

Key takeaways from this topic...

1. Constants in C++ are fixed values that do not change during program
execution and are defined using the const keyword
2. Literals are specific values directly written into the code, such as numbers or
characters, that represent fixed data of a particular type.
3. Structures and unions in C++ are user-defined types for grouping data, with
structures allowing different types of data to be combined and unions sharing
the same memory space for multiple data types, while enums define a set of
named integer constants for better code readability and management.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Literals


A literal is a fixed value that is written directly into the source code. Literals are
compiled into constants with the values in the source code.

In the following example, Hello world! and 5 are literals.

int x = 5;

cout << "Hello world!" << endl;

Both literals and variables have a value, and they both have a type. The type of a
variable is given in its declaration. The type of a literal is assumed from the value
and format of the literal itself.

Types of Literals

Literals can be of any primitive (built-in) data type:

● Integer
● Floating-point (includes float and double)
● Character
● String
● Boolean

Section 2: Understanding Constants

Defining constants

Constants are treated just like regular variables except that their values cannot be
modified after their definition. Use a constant variable to avoid accidentally changing
a variable that should not change.
There are two simple ways in C++ to define constants—by using:

● const keyword
● #define preprocessor

const

We can use the const prefix to declare constants with a specific data type. The
syntax for creating a constant variable is:

const type variableName = value;

The constant variables should be initialised with a value when the variable is
created.

const double PI = 3.141592653589793238;

If we try to change the value of the constant variable after its initialisation, we will get
an error

PI = 231.424; // this line will result in a compile error

#define preprocessor

Another mechanism to name constant values is to use the #define preprocessor


directive. The syntax of the preprocessor directive is:

#define identifier replacementValue


After this directive, any occurence of identifier in the code is interpreted as
replacementValue, where replacementValue is any sequence of characters (until the
end of the line).

#define PI 3.141592653589793238

This is a blind replacement as it is performed by the preprocessor, and happens


before the program is compiled. The validity of the types or syntax involved will not
be checked in any way.

Section 3: User-Defined Datatypes - Structures, Unions and Enumerations

Structures

Structure is a user-defined data type. It is used to combine different data types into
one unit.

It is declared using the keyword struct.

Unions

Unions are user-defined data types. Similar to structures, they can declare and
contain members of different data types. How they differ from a structure is that
member variables in a union share the same memory location.

It is declared using the keyword union.

Enumerations (Enums)
Enums are user-defined data types that contain named integral constants. Enums
help to assign constants into a set of names, which makes programs more readable.

It is declared using the keyword enum.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Converting unsigned integers to signed integers can lead to hidden
bugs
This blog post demonstrates the dangers of converting between two data types that
you learnt about in this week’s lectures, signed and unsigned integers. It is
exceptionally useful to understand how your programs might have accidental
problems, and this is a common source of problems.

Converting unsigned integers to signed integers can lead to hidden bugs

Links to an external site.

Reference: Pluralsight (2016) 'Converting unsigned integers to signed integers can lead to hidden
bugs', available at:
https://www.pluralsight.com/blog/software-development/convert-unsigned-int-to-signed-int [accessed
16/09/2024]

Reading: C++ Operator Precedence


This article details how operator precedence functions in C++. It is very easy to
introduce errors in your program by not understanding which order operators will be
executed. Understanding the order allows you to write programs faster and without
precedence errors.

C++ Operator Precedence

Links to an external site.


Reference: cppreference.com (n.d.) 'C++ Operator Precedence', cppreference.com wiki, available at:
https://en.cppreference.com/mwiki/index.php?title=cpp/language/operator_precedence&oldid=118915
[accessed 16/09/2024]

Reading: Structures, Unions and Enumerations in C++


This tutorial details how Structures, Unions and Enumerations work in C++. It is very
useful to use these user-defined data types in your programs. Understanding this
allows you to write programs that are well-organised.

Structures, Unions and Enumerations in C++

Links to an external site.

Reference: Geeksforgeeks (2024) 'Structures, Unions and Enumerations in C++', Geeksforgeeks,


available at: https://www.geeksforgeeks.org/structures-unions-and-enumerations-in-cpp/ [accessed
16/09/2024]

Reading: C++ Unions


This tutorial details how Unions works in C++. It is very useful to use this
user-defined data type in your programs to keep them well organised.

C++ Unions

Links to an external site.

Reference: Geeksforgeeks (2024) 'C++ Unions', Geeksforgeeks, available at:


https://www.geeksforgeeks.org/cpp-unions/ [accessed 16/09/2024]
Module 3. Control Structures and Data Structures -
Part 1
In this module, you will advance your programming skills by learning how to create
paths in your programs based on your data. For example, you may want your
program to add two variables together with the addition operator if some data is a
certain value, but if that data is not that value you may instead want to multiply those
two variables together.

The process of creating paths that your program can follow is achieved with
conditional statements. This is the basis of AI (Artificial Intelligence) as your program
is now able to make decisions for itself based on the data you provide it!

During the lectures, you will learn about the many conditional statements that C++
provides, such as the If condition statement that lets your program execute
instructions only if some data is a specific value. If it is not that specific value you can
instruct your program to execute other instructions using an else conditional
statement.

Data structures are fundamental to computer science and programming, providing a


means of organising and storing data in a computer so that it can be accessed and
modified efficiently. Understanding how to work with different types of data
structures, such as lists, arrays, and linked lists, is vital for any software developer or
computer scientist.

In this module, you will:

● Explore solutions for handling conditional and repetitive statements and


how they are used in real-world applications.
● Learn about conditional statements, including how to write programs that
demonstrate this essential concept.
● Discover the methods for handling repetitive statements in projects,
promoting efficient looping constructs.
● Learn what data structures are, their importance, and their application in
programming.
● Investigate the process of creating applications, focusing on the
application of data structures.

To enhance your understanding, we have tailored specific learning activities:

● Write a program to find the minimum of three numbers


● Write a program to display a multiplication table
● Create an array and loop through it.
Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 2: Gain the ability to create and modify basic data structures such as
arrays and linked lists, along with performing operations like insertion,
deletion, and traversal.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Conditional Statements

Key takeaways from this topic...


1. The if statement in C++ executes a block of code if a specified condition is
true, allowing for basic decision-making.
2. else and else-if provide additional pathways for code execution when the
initial if condition is false, enabling multiple conditions to be tested
sequentially.
3. The switch statement offers a way to select and execute code from multiple
potential branches based on the value of a variable, simplifying complex
conditional logic.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Conditional Statements

This module introduces you to the conditional statements that C++ provides—if, if
else, if … else, switch, ?:, and also how to nest these conditions amongst each other.
To use these statements you will need to use relational operators which you learnt
about in the previous module, and we will recap again.

By combining both relational operators and conditional statements you can make
your programs make decisions! To understand the decisions that the program makes
you will learn about flowcharts which will provide a visual way of representing the
decisions and the outcomes.

if statement

Programs often take actions based on conditions, only executing particular


statements when some condition is true. The if statement selects and executes one
or more statements based on some condition. If the condition is true, then the
statements in the if block are executed. If the condition evaluates to false then the
statements are skipped and the program control passes to the statement following
the if statement.

Example:

if (age >= 18)

{
cout << “You may enter!\n”;
}

if...else statement

Depending on the outcome of the condition, the if...else statement causes one of the
two possible statement(s) to execute.

An if statement can be followed by an optional else statement, which executes when


the condition is false. If the condition evaluates to true, the statement(s) inside the
body of if is executed. If the condition evaluates to false, the statement(s) inside the
body of else is executed.
Example:

if (age >= 18)

{
cout << “You may enter!\n”;
}

else

{
cout << “You aren't old enough.\n”;
}

Switch case statement

A switch case statement is used when we have multiple conditions that lead to
different outcomes. We can use lengthy if...else if...else, but it gets messy with more
than a few possible outcomes.

The switch case is a clean and efficient method of handling multiple conditions.

Example:

switch (age)

case 16:

cout << “Sweet sixteen!\n”;

break;
case 18:

cout << “Welcome to adulthood!\n”;

break;

case 50:

cout << “The good stuff starts now!\n”;

break;

default:

cout << “This is a great age!\n

break;

Topic 2. Loops

Key takeaways from this topic...

1. The for loop in C++ is used for iterating over a sequence of values with a
known number of iterations, defined by initialisation, condition, and increment
expressions.
2. The while loop repeatedly executes a block of code as long as a specified
condition remains true, suitable for scenarios where the number of iterations
is not known in advance.
3. The do-while loop guarantees that the block of code will run at least once
before checking the condition, making it useful for cases where an initial
execution is necessary.
Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Loops

In this topic, you'll catapult the effectiveness


of your programs by adding loops. Up until now, your instructions will have been
executed once by the computer, but using loops you will be able to instruct the
computer to execute instructions as many times as you wish. 1 time, 10 times,
infinite times!

This topic introduces you to the three types of loop statements that C++
provides—for, while, do while. Like conditional statements, you need to use relational
operators. By combining both relational operators and loop statements you can
instruct your programs to execute a set of instructions as many times as you like.
You can also instruct the program to stop a loop by using special keywords in C++,
which we will soon cover.

Imagine a game that runs until the player closes it, to achieve this you will tell the
computer to run a sequence of instructions over and over again, using a loop, until
the player presses the quit button. Loop statements allow you to specify how many
times you want the computer to run a specific set of instructions. Flowcharts will
again be demonstrated to visualise how the computer will loop over your instructions.

What are loops?

So far, we have been writing statements that get executed sequentially, one
statement followed by another. Loops allow a programmer to repeatedly execute a
block of statements until a condition is satisfied.

Let’s say we want to print “Hello, world!” 5 times. We could do it sequentially, like
this:

cout << "Hello, world!" << endl;


cout << "Hello, world!" << endl;
cout << "Hello, world!" << endl;
cout << "Hello, world!" << endl;
cout << "Hello, world!" << endl;

Or we can use loops to make our code leaner, more efficient and DRY.

DRY: Don’t Repeat Yourself


A key programming principle that you should aspire to is DRY code, meaning that
when possible, avoid repeating lines of code. This is important because it makes our
code easier to read and maintain. If we repeat code, and that code requires a
change, we have to remember to make the change in multiple places if the code is
repeated.

Loops are one tool you can use to keep code DRY.

Loop types

C++ programming language provides the following types of loops:

for loop

for (init; condition; expression)


{
statement(s);
}

Example:

int main()
{

for (int i = 0; i < 10; ++i)


{
cout << "hello, world!" << endl;
}

return 0;
}
while loop

while (condition)
{
statement(s);
}

Example:

int main()
{

int m = 1;

while (m <= 10)


{
cout << "hello, world!" << endl;
m++;
}

return 0;

do...while loop

Syntax:

do
{
statement(s);
} while (condition);
Example:

int main()
{

int m = 1;

do
{
cout << "Value of m: " << m << endl;
m++;
} while (m <= 6);

return 0;
}

Nested loops

The body of a loop can contain another loop known as a nested loop. The inner loop
must be completed each time through the outer loop.

In the following example, the ‘row’ loop starts first, then enters the ‘column’ loop and
executes the statements inside the column loop until it reaches 5 loops or iterations.
Then, it exits out of the column loop and goes through the row loop again as the
steps are repeated until the number of iterations through the ‘row’ loop reaches 5.

for (int row = 1; row <= 5; row++)


{

for (int col = 1; col <= 5; col++)


{
cout << "row " << row << ", col " << col;
cout << "\t";
}
cout << endl;
}

Loop control statements

Sometimes, you might want to skip the execution of a loop for a certain condition or
terminate it immediately without checking the condition. In C++ there are two
statements to specifically alter the normal flow of a loop. They are:

● break
● continue

For example, we want to loop through the data of all aged people except those aged
55. Or if we want to find the first person aged 20. In these scenarios, break and
continue statements can be used.

Topic 3. Introduction to Data Structures

Key takeaways from this topic...

1. The foundational understanding of data structures allows for more efficient


data management and manipulation in software development.
2. Data structures are not one-size-fits-all; different types serve different
purposes, be it stacks, queues, arrays, or linked lists.
3. Data structures play a critical role in the efficiency of algorithms, directly
affecting computational complexity and runtime.
Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Data Structures

source: Geeks for Geeks

Data structures serve as the backbone for organising information in the realm of
programming. Much like how a library arranges books on shelves, data structures
help you organise and store data in your programs. Understanding how to properly
utilise these structures will set you on a path towards becoming a proficient
programmer.

Types of Data Structures

Different tasks call for different types of organisation. In the world of data structures,
you have several options to fit your specific needs:

Linear Structures

● Arrays: Fixed in size, arrays offer quick access but fall short when it
comes to dynamic resizing. They’re best for situations where you know the
size of the data set in advance.

● Linked Lists: Comprising nodes connected by pointers, linked lists are


dynamic, making it easier to insert and delete elements. However, this
flexibility comes at the cost of slower data retrieval compared to arrays.

Hierarchical Structures

● Trees: Imagine a tree with a trunk, branches, and leaves. A tree structure
starts with a root node, which branches off into several sub-nodes, and so
on. Trees are commonly used in databases to facilitate quick data
retrieval.

● Graphs: Unlike trees, graphs can have nodes that are interconnected in
complex ways, allowing for a more flexible representation of relationships
between elements. They’re commonly used in network routing and social
networking applications.

Tabular Structures
● Hash Tables: These are akin to a magical library where you whisper the
name of a book and it appears before you. Hash tables use a unique key
to store data, offering almost instantaneous data lookup.

● Dictionaries: Similar to hash tables but often with a focus on key-value


pairs, dictionaries are utilised when you need to associate specific values
with unique keys.

Further Reading

Introduction to Data Structures

Links to an external site.

The choice of a good data structure makes it possible to perform a variety of critical
operations effectively. A data structure is not only used for organising data but also
for processing, retrieving, and storing data. Explore further the different categories of
data structures and the most commonly used types.

Reference: Geeks for Geeks n.d., Introduction to Data Structures, Geeks for Geeks, accessed 30
January 2024, <https://www.geeksforgeeks.org/introduction-to-data-structures/>

Section 2: The Importance of Data Structures


source: freepik

Links to an external site.

Why Data Structures Matter

● Efficiency
The right data structure optimises both time and memory. In turn, this
makes your program run more swiftly, making tasks like data retrieval and
storage more effective.

● Ease of Operations
Data structures make it simpler to add, remove, or modify data. As your
programs grow more complex, this flexibility becomes increasingly
important.

● Data Organisation
When data is well-organised, your algorithms run more smoothly, making
your programs more reliable and user-friendly.
Section 3: QuickShop Case Study

source: freepik

Links to an external site.

Background

QuickShop, a fast-growing supermarket chain, identified that its current inventory


management system was becoming a bottleneck in its operations.

As the inventory grew, the existing system struggled to maintain performance levels,
causing delays in various processes including stock checks and billing. Realising the
critical role of data structures in efficient data management, QuickShop decided to
revamp its inventory system.

The Challenge
The central challenge was to design a system that could handle a vast and dynamic
range of products while ensuring quick and accurate data retrieval. The system
needed to facilitate seamless additions and removals of items, track inventory levels
in real-time, and offer rapid search capabilities to enhance the customer experience
at the checkout points.

The Strategy

QuickShop’s IT team proposed leveraging different data structures to build a


versatile and efficient inventory management system. The strategy involved the
integration of arrays, linked lists, and hash tables in various components of the
system. Here’s how they planned to do it:

● Arrays for Fixed Categories


Arrays were implemented to categorise items into fixed groups like
perishables, non-perishables, etc., allowing for quick and easy sorting and
filtering of products based on their categories.

● Linked Lists for Dynamic Inventory


Understanding that the inventory was dynamic and constantly changing,
linked lists were employed to manage the list of products within each
category, facilitating efficient additions and removals of items.

● Hash Tables for Quick Item Lookup


To revolutionise the checkout process, hash tables were introduced. Each
product was associated with a unique barcode as a hash key, enabling
instant retrieval of product details during billing, thereby reducing the
checkout time significantly.

Implementation

A cross-functional team involving IT specialists and operations managers worked


hand-in-hand to execute the plan. After weeks of development and testing, the new
system was launched. The team conducted extensive training to familiarise the staff
with the new system and ensure a smooth transition.
Outcome

With the new system in place, QuickShop witnessed a remarkable improvement in


their operations:

● Increased Efficiency
The system allowed for quicker data access and manipulation,
considerably reducing the time taken for inventory management and billing
processes.

● Improved Customer Experience


Customers enjoyed a quicker checkout process, enhancing their overall
shopping experience at QuickShop.

● Ease of Scalability
As QuickShop expanded, adding new products and categories to the
inventory became a seamless process, enabling the supermarket to grow
without being hindered by its systems.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: C++ Decision-Making with if, if...else
This article explains in detail, with examples, how to effectively use the if, if...else
and Nested if...else decision-making statements in C++.

C++ if, if...else and Nested if...else

Reference: Programiz, 2024, 'C++ if, if...else and Nested if...else', Programiz (online), accessed 16
Sept 2024, <https://www.programiz.com/cpp-programming/if-else>

Reading: C++ switch..case


The switch statement allows us to execute a block of code among many alternatives.
This article explains in detail, with examples, how to effectively use switch cases.

C++ switch..case Statement

Reference: Programiz, 2024, 'C++ switch..case Statement', Programiz, accessed 16 Sept 2024,
<https://www.programiz.com/cpp-programming/switch-case>

Reading: C++ Loops


The following tutorial articles from Programiz explain in detail, with examples, how to
effectively use various types and elements of loops.

● C++ for Loop


● C++ while and do...while Loop
● Links to an external site.

● C++ break Statement
● Links to an external site.

● C++ continue Statement
● Links to an external site.

Reference: Programiz, 2024, 'Flow Control', C++ Programming, Programiz, accessed 16 Sept. 2024,
<https://www.programiz.com/cpp-programming/>

Reading: Introduction to Data Structures


Data structures are methods for organising data to optimise efficiency in terms of
space and time, crucial for effective software development. This article explains the
various types of data structures, including linear structures like arrays and linked
lists, as well as non-linear ones like trees and graphs, each serving distinct purposes
for managing and processing data. Understanding these structures is essential for
developers to handle data effectively across diverse applications in programming
and system design.

Introduction to Data Structures

Reference: Geeks4Geeks, 2024, 'Introduction to Data Structures', Geeks4Geeks, accessed 16 Sept.


2024, <https://www.geeksforgeeks.org/introduction-to-data-structures/>

Video: Data Structures Explained


This video is an introduction to the concept of data structures, and its purpose is to
explain the idea behind them, in under 5 minutes, using understandable and
relatable examples.

Data Structures Explained (04:44)

See also CodeBeauty's playlist "C++ for Beginners

Links to an external site.

" that covers all of the concepts from this and previous modules.

Reference: CodeBeauty, 2021, 'Data Structures Explained', YouTube, accessed 16 Sept. 2024,
<https://www.youtube.com/watch?v=_T42E9RkWVQ>
Module 4. Data Structures Pt. 2
Data structures continue to play a crucial role in computer science, enabling efficient
data management and manipulation. Building upon the foundation laid in Part 1, this
module delves further into advanced data structures such as stacks, queues and
linked lists.

In this module, you will explore:

● Discover the functionality and structure of lists and arrays, and how to
manipulate them in different programming environments.
● Gain insights into linked lists, understanding how to build and operate
them, including insertion, deletion, and traversal.
● Learn about the structure and functionality of stacks, queues, and binary
trees, and how they can be utilised in programming.
● Discover the principles of graphs, sets, and hash tables, and understand
how to manipulate them in various programming environments.
● Design and manipulate user-defined data structures, integrating them into
real-world applications.

To enhance your understanding, we have tailored specific learning activities:

● Create an array and perform basic operations like insertion and deletion
● Implement stacks and queues using C++.
● Build a singly linked list and perform operations like insertion, deletion, and
traversal.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 2: Gain the ability to create and modify basic data structures such as
arrays and linked lists, along with performing operations like insertion,
deletion, and traversal.

Student Expectations
During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Lists and Arrays

Key takeaways from this topic...

1. Lists can be either static or dynamic. Static lists have a fixed size, while
dynamic lists (dynamic arrays) can grow or shrink at runtime.
2. Operations like insertion and deletion are fundamental to understanding how
lists and arrays work.
3. Lists and arrays are used in various applications such as managing
databases, building temporary data storage, and data retrieval.

Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Fundamental Concepts

For a programmer, grasping foundational concepts such as data structures is crucial.


Specifically, lists and arrays serve as vital tools, operating like containers where you
can neatly arrange and manage a plethora of items or elements. In this guide, we
shall embark on a journey to comprehensively explore lists and arrays, using some
practical examples and a real-world case study to cement your understanding.

Understanding Lists

In the programming lexicon, a list stands as a dynamic data structure capable of


holding an ordered collection of items, which can vary vastly in type. These lists are
a cornerstone in the programming domain, renowned for their versatility and
efficiency in managing large volumes of data. Let’s look deeper into the
characteristics that make lists so essential:

● Dynamic Size
○ A list is akin to a magic bag that adjusts its size to
accommodate or remove items as necessary, showcasing a
dynamic nature.
○ Example: Imagine creating a to-do list where you can
continually add new tasks and remove completed ones without
any restriction.
● Ordered Collection
○ Lists are known to maintain a systematic order, ensuring every
item is accessible based on its position or rank in the list.
○ Example: Consider a playlist where songs are arranged in a
specific order, allowing you to find and play any song based on
its position in the list.

Understanding Arrays

Arrays stand as another pivotal data structure, designed to hold more than one value
at a time. They can be visualised as a collection of variables, each identified with a
unique index number, facilitating rapid access. The primary attributes of arrays
include:

● Fixed Size
Contrary to lists, arrays in C++ have a fixed size, which is determined at
the time of creation and cannot be changed thereafter. It's a limitation that
requires the size to be known at compile time. However, you can use
vectors in C++ if you need a dynamic size similar to lists.
● Index-Based Access
In C++ arrays, each element is identified by a unique index number,
allowing swift and direct access to any element based on its position in the
array.

Further Reading

Data Structures in C++ | Array | Linked List | Stack

Links to an external site.

Depending on your project requirements, it is important to choose the right data


structure for your project. Explore further the common data structures of the array,
list, and stack to gain an understanding of how you might use them in a project.

Reference: Abhishek Sharma 2022, 'Data Structures in C++ | Array | Linked List | Stack', PrepBytes
Blog, accessed 30 January 2024,
<https://www.prepbytes.com/blog/arrays/data-structures-in-c-array-linked-list-stack/>

Section 2: Strategies for Effective Use of Lists and Arrays

source: BoardInfinity

Links to an external site.

Strategies for Using Lists and Arrays Effectively

When navigating lists and arrays, the selection of the right data structure based on
your specific requirements is imperative. But how do you decide on the right one?
Let's look at strategies that can guide you to use these structures most effectively:

● Choosing the Right Data Structure


○ Depending on your operations, be it insertion, deletion, or
retrieval, selecting an appropriate data structure can markedly
enhance efficiency.

○ Example: In a library system, using a list to store a dynamically


changing number of books and an array to manage fixed
categories of genres can be an optimal strategy.
● Efficient Memory Usage
○ Being mindful of your program’s memory consumption is pivotal.
At times, arrays might offer better memory efficiency compared
to lists due to their fixed size.

○ Example: When dealing with a large dataset, considering


memory usage can prevent potential system overloads,
ensuring smooth operation.
● Leveraging Built-in Functions
○ Various programming languages present a large range of
built-in functions that can facilitate smooth operations with lists
and arrays, promoting cleaner code.

○ Example: By familiarising yourself with built-in functions, you


can perform complex operations such as sorting or filtering data
in lists or arrays with minimal code.

Section 3: Case Study: Implementing an Efficient Inventory System at BrightMart

source: freepik
Links to an external site.

Background

BrightMart emerged as a beacon of rapid growth in the retail sector, with a


burgeoning customer base that was continually escalating. To keep pace with the
growing demands and to fortify their market position, the management identified the
need to enhance their inventory management system. The objective was clear: to
overhaul the existing structure and implement a system that would streamline
operations, enhance customer satisfaction, and support sustainable growth. To
achieve this, a strategic decision was made to develop a hybrid system that adeptly
utilises both lists and arrays to manage product information dynamically and
effectively.

Problem Statement

In the initial phase, the management identified a few pressing issues with the current
inventory system:

● Delayed Access to Product Information: The existing system was unable


to provide quick access to product data, causing delays in customer
service.

● Inefficient Inventory Tracking: Inventory levels were not tracked accurately,


leading to overstocking or understocking of products.

● Limited Scalability: The current system couldn’t effectively accommodate


the growing range of products and categories that BrightMart was offering.
Planning and Strategy

To address these issues, a comprehensive plan was crafted.

● Research and Development: A dedicated team was tasked with


researching and developing a state-of-the-art inventory system. This team
spent weeks understanding the nuances of lists and arrays and how they
could be leveraged to create a flexible, scalable, and efficient inventory
system.

● Stakeholder Engagement: A series of workshops were conducted with


various stakeholders, including sales, warehouse management, and IT
personnel, to gather insights and inputs for developing a system that
meets the needs of all stakeholders.

● System Design: Based on the inputs received and the research


conducted, a hybrid system design was conceptualised that would
integrate the versatility of lists with the stability and speed of arrays.

Implementation

The implementation phase saw the translation of planning into action:

● Product Categories with Arrays: Arrays were chosen to manage product


categories. Given their fixed size, arrays allowed for a stable and
structured approach to categorise products. This strategy facilitated rapid
and easy access to different categories, enhancing the efficiency of the
search functionality.

● Individual Product Details with Lists: On the other hand, lists were
employed to manage individual product details within each category. Lists,
with their dynamic size, allowed for seamless addition or removal of
products, offering flexibility in managing the ever-changing inventory
dynamics.
● Training and Deployment: Before full-fledged deployment, staff were
trained to adapt to the new system, followed by a phased rollout to ensure
smooth transition without hindering the daily operations.

Outcome

BrightMart witnessed a transformative change:

● Efficiency Improvement: The new system drastically improved the


efficiency of the inventory management process. Tasks that previously
took hours were now being completed in a fraction of the time, enhancing
productivity across departments.
● Enhanced Customer Satisfaction: The streamlined process meant
customers could now enjoy quicker check-outs and better service, leading
to improved customer satisfaction and loyalty.
● Data-Driven Decision Making: The system facilitated real-time tracking
and reporting of inventory levels, enabling management to make informed,
data-driven decisions, and optimise stock levels effectively.

Topic 2. Stacks and Queues

Key takeaways from this topic...

1. Stacks operate on Last-In-First-Out (LIFO) principles, while queues operate


on First-In-First-Out (FIFO) principles.
2. C++ classes can encapsulate the functionality of these data structures,
providing a clean and reusable codebase.

Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Stacks and Queues

Stacks

In computer science, a stack operates similarly to a physical stack of objects. The


structure follows a Last-In-First-Out (LIFO) approach, meaning the most recently
added item is the first one to be removed. This feature is integral in various
computational scenarios.

● Push: This operation adds an item to the stack, expanding its size. It
places a new item on top of the stack, ready to be the first to be removed
when the time comes.
● Pop: This function removes the top item from the stack, reducing its size.
It facilitates the retrieval and removal of the most recently added item.
● Peek: A utility function that permits viewing of the top item without its
removal, providing a way to know the item at the top without altering the
stack structure.
Learn more about Stack operations

Practical Applications

● Undo Mechanism: In text editors, stacks facilitate the undo functionality,


allowing users to reverse the most recent changes sequentially.
● Backtracking Algorithms: They are also essential in algorithms where
backtracking is necessary to find solutions, such as in maze-solving
algorithms.
Explore practical applications of Stacks

Queues
A queue is analogous to a line of people at a bank, adhering to a First-In-First-Out
(FIFO) principle. This system ensures that the first item added is the first to be
removed, maintaining an order based on the addition time of the elements.

● Enqueue: This method adds an item to the rear of the queue, ensuring the
maintenance of the FIFO structure.
● Dequeue: This method removes an item from the front of the queue,
abiding by the FIFO rule.
● Front: This function allows the viewing of the front item without its
removal, providing insight into the next item to be dequeued without
altering the queue structure.
Learn more about Queue operations

Practical Applications

● Order Processing Systems: Queues manage orders in systems,


processing them in the order they were placed, ensuring fairness and
orderliness.
● Print Queue Management: In networked environments with many users
needing to print documents on a single printer, queues manage the print
jobs in the order they were requested.
Explore practical applications of Queues

Section 2: Case Study - Modernising a Public Transport System

source: RMIT Centre for Urban Research

Background

In an attempt to modernise its public transportation system and enhance the daily
commuting experience of its citizens, the MetroCity local government initiated a
project to integrate technology-driven solutions.

They identified that the incorporation of specific data structures — stacks, queues,
and trees — could play a pivotal role in addressing current inefficiencies and offering
an improved, streamlined service.

Problem Statement

MetroCity was grappling with a congested and disorganised public transport network.
Commuters were often met with irregular bus services, unclear transit routes, and
overcrowded vehicles. Moreover, the existing system lacked a proper method to
gather and utilise data for planning and optimisation. MetroCity needed a
transformative solution to organise and streamline its transport services.
Implementation

To improve the system, MetroCity introduced a digital platform that utilised the
principles of stacks, queues, and trees data structures in the following manner:

● Stacks for Service Maintenance: The corporation implemented a


stack-based system for maintaining and servicing the bus fleet. The buses
were serviced in a LIFO (Last In, First Out) manner, ensuring the buses
that were used more intensively received more frequent maintenance,
thus extending the lifespan of the vehicles.
● Queues for Passenger Management: At bus stops, a queue system was
introduced to manage the passenger influx systematically. This FIFO (First
In, First Out) system ensured a fair and organised way for passengers to
board the buses, reducing chaos and overcrowding.

Outcome

The project significantly improved the efficiency and user-friendliness of MetroCity’s


public transport system. The tree structure offered clear and optimised routes,
reducing travel time and enhancing the commuter experience. The stack and queue
systems ensured well-maintained vehicles and organised boarding processes,
fostering a more civilised and systematic transportation environment.

Topic 3. Linked Lists

Key takeaways from this topic...

1. Linked lists can be singly linked or doubly linked. Singly linked lists contain
pointers to the next node, while doubly linked lists contain pointers to both the
next and previous nodes.
2. Linked lists are dynamic data structures, which means they can easily grow or
shrink during execution.
3. Operations like insertion, deletion, and traversal require an understanding of
pointers and the interconnected nodes to be efficient.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Introduction to Linked Lists

source: freepik

Links to an external site.


Understanding Linked Lists

In the realm of data structures, a linked list holds a significant place. It is essentially a
linear collection of data elements or nodes, wherein each element points to the next
one, forming a sequence or link.

● Node Structure: Each node in a linked list comprises two components:


the data and a reference to the next node. This structure forms the
backbone of the linked list, ensuring a sequential and dynamic flow of
data.
● Dynamic Structure: The dynamic nature of linked lists offers versatility in
data management. This feature allows for smooth additions or deletions of
elements at different positions, with memory being allocated or
deallocated at runtime, which can be particularly beneficial when dealing
with fluctuating data sizes.

Types of Linked Lists

There are different variations of linked lists, each catering to different needs:

● Singly Linked List: Contains nodes which have a data part and a link to
the next node in the sequence.
● Doubly Linked List: Each node contains, besides the next-node link, a
second link field pointing to the ‘previous’ node in the sequence, which
facilitates traversal in both directions.
● Circular Linked List: The last node in the list points back to the first node,
forming a closed loop.

Further Reading
Understanding the Basics of Linked List

Links to an external site.

Explore the purpose and structure of linked list with visual representations of the
different types.

Reference: Geeks for Geeks n.d., Understanding the Basics of Linked List, Geeks for Geeks,
accessed 30 January 2024, <https://www.geeksforgeeks.org/what-is-linked-list/>

Section 2: Practical Applications of Linked Lists

Memory Allocation

Unlike arrays, linked lists do not allocate a contiguous memory block; instead,
memory is assigned as and when a new node is added. This dynamic memory
allocation can prevent wastage of memory space and offer more flexibility in data
handling.
Insertion and Deletion

In linked lists, the insertion and deletion of nodes are more straightforward
processes. You are not shifting the elements but merely changing the links, which
can be done in constant time, thereby saving computational resources.

Real-World Applications

Linked lists find their application in various real-world scenarios. Here are a few
examples:

● Music Playlists: In music applications, where songs can be added or


removed dynamically.
● Browser Cache: Utilised in browsers to implement forward and backward
navigation of web pages.
● File Management Systems: Employed in operating systems for file storage
and management.

Section 3: Case Study: Enhancing a Social Media Application

source: freepik
Links to an external site.

Background

In the ever-evolving digital landscape, social media platforms stand as bustling hubs
of interaction and content exchange. Imagine a particular platform, let’s call it
‘SocialSphere’, that has witnessed an exponential growth in its user base in recent
years. Initially, the user feed mechanism was based on an array data structure.
However, as the platform expanded, it became increasingly apparent that the
array-based structure was struggling to keep up with the dynamic nature of user
feeds, leading to slower updates and a less responsive user interface.

Preliminary Challenges

The initial system faced significant challenges, mainly revolving around:

● Inefficiency in Data Management: The existing array-based structure


had difficulty accommodating the frequent updates, deletions, and
additions occurring in real-time.
● Scalability Issues: The large volume of users and the consequent data
generated was becoming too great for an array structure to manage
efficiently, leading to scalability issues.
● Delayed Updates: Users started noticing a lag in their feed updates,
which slowed the real-time interaction that is often expected on such
platforms.

Implementation
To overcome these challenges, the development team at SocialSphere embarked on
rethinking their data management strategy. They realised that a doubly linked list
would serve as an ideal solution, as it could handle dynamic data more efficiently.
Here’s how they approached the revamping process:

● Choosing a Doubly Linked List: After a series of deliberations, the team


chose a doubly linked list data structure for its dynamic nature and ease of
inserting or deleting nodes, which would facilitate real-time updates in user
feeds.
● Customising the Data Node: Each node in this list contained not just the
post data, but also links to the previous and next posts, allowing for a
seamless navigation experience.
● Transitioning Data: A critical phase was the migration of existing data to
the new structure without causing any disruption in services.

Testing and Deployment

Before the fully-fledged deployment, rigorous testing was carried out to ensure the
efficiency and reliability of the new system. The development team created
simulations to test the performance of the new structure under different loads and
conditions.

Outcome

Post-implementation, the changes were significant:

● Enhanced User Engagement: The user engagement levels surged, with


users finding their feed more responsive and constantly updated with fresh
content.
● Scalable Infrastructure: The new data structure allowed the platform to
efficiently handle the increasing data volume, showcasing excellent
scalability prospects.
● Positive User Feedback: Users appreciated the improvements, resulting
in positive reviews and an enhanced platform reputation.
Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Linked List Data Structure In C++
A linked list is a linear dynamic data structure to store data items. This article gives
further explanation of this data structure and demonstrates various operations that
can be performed on linked list with code examples.

Linked List Data Structure In C++

Links to an external site.

Reference: (2023) 'Linked List Data Structure In C++', Software Testing Help, accessed 30 January
2024, <https://www.softwaretestinghelp.com/linked-list/>

Reading: Data Structures in C++ - Array | Linked List | Stack


Depending on your project requirements, it is important to choose the right data
structure for your project. This article explores further the common data structures of
the array, list, and stack to gain an understanding of how you might use them in a
project.

Data Structures in C++ - Array | Linked List | Stack

Links to an external site.

Reference: Sharma, A. (2022) 'Data Structures in C++ | Array | Linked List | Stack', PrepBytes Blog,
accessed 16 Sept. 2024,
<https://www.prepbytes.com/blog/arrays/data-structures-in-c-array-linked-list-stack/>
Module 5. Modular Programming & Algorithms Pt. 1
The practice of modular programming and understanding of standard algorithms is
central to efficient coding and software development. This module introduces the
principles of modular programming and explores some of the standard algorithms
that are commonly used in the industry. From breaking down complex code to
understanding sorting techniques, this module is a step towards mastering the
building blocks of programming.

In this module, you will explore:

● Learn the modular programming approach, breaking down complex


programs into manageable and reusable modules or functions.
● Discover standard algorithms, understanding their structure, and
application in programming environments.
● Gain insights into pass-by-reference parameter passing, and how it affects
the calling variables.

To enhance your understanding, we have tailored specific learning activities:

● Break down a complex program into smaller modules or functions.


● Implement and compare standard sorting algorithms like bubble sort and
quick sort.
● Write a function that uses pass-by-reference and demonstrates its effect
on the caller's variables.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 3: Learn to implement complex data structures like stacks, queues,


trees, and graphs, as well as algorithms for sorting and searching.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.
Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Modular Programming Approach

Key takeaways from this topic...

1. One of the significant advantages of modular programming is the ease of


code reusability. Smaller, function-specific modules can be reused across
different parts of an application.
2. Breaking down a complex program into smaller modules makes it easier to
debug, as issues can be isolated and addressed individually.
3. In a team setting, modular programming allows multiple developers to work on
different modules simultaneously, increasing productivity.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.
Expand All

Panels

Collapse All

Panels

Section 1: Understanding Modular Programming

In the fast-paced
world of software development, efficiency and adaptability are key to meeting
ever-changing demands. Modular programming serves as a beacon in this regard,
promising streamlined processes and enhanced productivity.

This approach, which is becoming increasingly popular, divides a program into


separate, functionally independent modules. These modules, which can be
developed independently, function harmoniously when integrated, thus facilitating a
coherent and efficient system.

The characteristics of this approach are as follows:

● Separation of Concerns
This principle dictates that a program should be segmented into distinct
sections, with each handling a specific aspect of the functionality. This
separation ensures a cleaner, more organized code base which is easier
to maintain and upgrade.
● Reuse of Code
Modular programming encourages the development of reusable modules
that can find utility in various projects, promoting efficiency and reducing
the overall development time.
● Ease of Maintenance: One of the standout benefits of this approach is
the ease with which modules can be updated, added, or removed
individually, without affecting other parts of the program. This makes
maintenance less cumbersome and time-consuming.
● Increased Reliability
By isolating errors to individual modules, it becomes considerably easier to
identify and rectify issues, thereby enhancing the reliability of the software.

Benefits and Challenges of Modular Programming

Benefits

● Parallel Development
Different teams can work on separate modules simultaneously, which can
significantly speed up the development process.
● Improved Testing
Each module can be tested individually, thereby ensuring higher reliability
and stability of the system.

Challenges

● Integration Issues
Although modules are developed independently, integrating them can
sometimes pose challenges, especially if the modules are developed by
different teams.
● Complexity
As programs grow in size and complexity, managing numerous modules
requires careful planning and coordination to prevent potential issues and
maintain coherence.
Section 2: Functions

A function is a group of statements with a name. We can only execute the group of
statements by using the name of the function. Every C++ program has at least one
function, which is main().

Why define functions?

● Prevent repetition (keep code DRY)


○ Makes code easier to understand and maintain
○ If you find yourself copying lines of code, you should probably
create a function
● Encapsulate an algorithm (a series of steps) with a single purpose and
give it a name
○ Makes code easier to understand and maintain
● Makes it easier to test code
○ Testing a function separately makes it easier to debug if there is
a flaw in logic
● Functions make your code easier to understand and maintain

Creating a function

The general form of a C++ function definition is:

return_type function_name (parameter_list) {


statement1;
statement2;
statement3;

return statement;
}
Parts of a function

● return_type
is the data type of the value of the function returns. Some functions
perform the desired operations without returning a value. In this case, the
return_type is the keyword void.
● function_name
is the actual name of the function. The function name and the parameter
list together constitute the function signature.
● parameter_list
A parameter is like a placeholder. When a function is called, we pass a
value to the parameter. This value is referred to as the actual parameter.
The parameter list refers to the type, order and number of parameters of a
function. Parameters are optional.
● body
The function body is between the curly braces {}, and contains the
statements executed by the function.
● The return statement terminates the current function and returns the value
of the function to its caller.

Function declaration

A minimal function declaration consists of the return type, function name and the
parameter list. For example:

int sum(int num1, int num2);

A function declaration must be done before calling the function.

The required parts of a function declaration are:

● The return type, which specifies the type of the value that the function
returns, or void if no value is returned.
● The function name, which must begin with a letter or underscore and
cannot contain spaces.
● The parameter list, a local name by which the values may be accessed
inside the function.

Function parameters

A function has a comma-separated parameters list of zero or more types.


Information can be passed into a function as a parameter.

Parameters act as local variables inside the function and are specified after the
function name, inside the parentheses.

We can add as many parameters as we want, separated by commas.

return_type function_name (parameter1, parameter2, parameter3) {


// code to be executed
}

Return values from a function

The void keyword, used in the examples before, indicates that the function should
not return a value. If we want the function to return a value, we can use a data type
(such as int, float, char, etc...) instead of void, and use the return keyword inside the
function.

Example 1

void printAge(int age) {


cout << "Your age is " << age<< endl;
}

void main() {
int myAge = 23;
printAge(23);
}

In the above example, the function prints the age.

Example 2

void add (int no1, int no2) {


int total = no1 + no2;
cout << "Total is " << total << endl;
}

void main() {
int x = 10;
int y = 5;
add (x, y);
}

In the above example, the function calculates the total.

Section 3: Case Study - Enhancing Efficiency in a Healthcare System

Background

ABC Healthcare, a healthcare provider, decided to enhance its existing software


system to improve efficiency and streamline operations. The goal was to employ a
modular programming approach to facilitate seamless integration of various
functionalities and services.

Problem Statement

The existing software system at ABC Healthcare was monolithic and rigid, making it
difficult to implement new features and upgrades. The system was also prone to
errors, with issues in one part often affecting the entire system. ABC Healthcare
sought a robust and flexible solution that would overcome these challenges.

Implementation

ABC Healthcare adopted a modular programming approach, segregating the


software system into several distinct modules, such as Patient Management,
Appointment Scheduling, and Billing. Each module was designed to handle specific
functionalities and could be developed and maintained independently. This approach
also facilitated:

● Separation of Concerns: Ensuring each module focused on a specific


function, enhancing efficiency and reducing errors.
● Code Reusability: Developing modules that could be reused in other
healthcare facilities within the ABC network, reducing development time
and costs.
● Parallel Development: Enabling different teams to work on separate
modules simultaneously, speeding up the development process.

Outcome

The modular approach transformed ABC Healthcare’s software system, making it


more flexible, reliable, and efficient. The system could easily adapt to changing
requirements, and new features could be implemented quickly and seamlessly. The
approach also enhanced the system’s reliability, as issues could be isolated and
resolved without affecting other modules.

Topic 2. Introduction to Standard Algorithms

Key takeaways from this topic...

1. Understanding different sorting algorithms like bubble sort and quick sort
provides insights into computational efficiency and time complexity.
2. Standard algorithms solve common problems and are widely applicable in
data science, machine learning, and general software development.
3. Comparing the performance of different algorithms is crucial for choosing the
most efficient solution for a given problem.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Introduction to Standard Algorithms


In the ever-evolving world of
computer science, algorithms operate as the centrepiece, offering a structured
pathway to solving complex problems. Specifically, standard algorithms emerge as
tried and tested procedures that address recurrent computational challenges with a
high degree of efficiency.

Their power lies in several features such as optimised resource utilisation, reducing
complexity, offering predictability and consistency, and showcasing adaptability and
scalability.

As we delve deeper into this module, we will illuminate two vital components of
standard algorithms: space complexity and sorting algorithms.

These foundational elements not only enhance your understanding but also equip
you to craft robust and proficient systems in the future.

Section 2: Delving Deeper into Space Complexity and Sorting Algorithms

Space Complexity

When we speak of space complexity, we refer to the quantitative analysis of the


amount of memory an algorithm needs during its execution. This facet is a critical
parameter to assess the efficiency of an algorithm, especially in settings where
memory availability is restricted. Having a firm grasp of space complexity assists
developers in formulating algorithms that solve problems while conserving valuable
memory resources. This section is dedicated to imparting a comprehensive
understanding of space complexity, including methods to calculate it and strategies
to optimise algorithms to minimise memory usage.

Sorting Algorithms

Next, we venture into the realm of sorting algorithms, a category of standard


algorithms specially designed to arrange a collection of items in a specific order,
such as numerical or alphabetical. These algorithms play a pivotal role in diverse
fields, facilitating the organisation of voluminous datasets, enhancing data retrieval
processes, and bolstering the efficient functioning of other algorithms.

Section 3: Case Study - Optimising an E-Commerce Warehouse

In the bustling hub of a thriving e-commerce


business, the warehouse stands as the nerve centre, managing a large range of
products ready to be dispatched to customers.

The company noticed a rising trend in delayed deliveries and identified that the
primary cause was the disorganised product retrieval process within the warehouse.
This led to the decision to optimise the warehouse operations using suitable
standard algorithms.

Objective

To streamline the warehouse operations by implementing an effective product sorting


system, which would enable quicker retrieval of products and consequently faster
deliveries.
Implementation

The team decided to implement a blend of sorting algorithms to organise the


products more efficiently within the warehouse. Here is a breakdown of the
strategies employed:

Bubble Sort Algorithm

● Application: Used for sorting less frequently bought items where the data
set is relatively small.
● Benefit: Simplicity and ease of implementation.

Merge Sort Algorithm

● Application: Applied to sort the products based on various categories such


as price or popularity, especially when dealing with larger datasets.
● Benefit: Offers a more efficient and faster solution for larger datasets
compared to bubble sort.

Quick Sort Algorithm

● Application: Utilised for dynamic sorting requirements, where products


needed to be sorted quickly based on changing criteria, such as seasonal
demands.
● Benefit: Fast and efficient, particularly with large datasets, adapting well to
varying sorting criteria.

Moreover, to further optimise the space utilisation in the warehouse, the team
analysed the space complexity of various processes and implemented strategies to
minimise memory usage in the warehouse management system.

Outcome
Post-implementation, the warehouse witnessed a substantial reduction in product
retrieval time, resulting in faster order processing and happier customers. The
meticulous sorting facilitated easy and quick access to products, optimising the
workflow and enhancing the overall efficiency of the warehouse.

Topic 3. Pass-by-Value Parameter Passing

Key takeaways from this topic...

1. Pass-by-value doesn’t allow a function to modify the caller's variables directly,


facilitating the original data to be kept unchanged.
2. Using pass-by-value doesn’t save memory, as it creates copies of data
including large data structures.
3. Pass-by-value can introduce fewer errors, as changes to the variable within
the function don’t affect its original value.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Pass-By-Value Parameter Passing


In programming, particularly in languages such as C++, parameter passing is a
technique where you provide inputs to functions. There are several methods to pass
parameters, and one of the most commonly used methods is "pass-by-value". This
method doesn’t facilitate the efficient use of memory but allows the data to be
protected as the function is unable modify the original data.

Understanding Pass-By-Reference

Pass-by-value is a parameter passing method where a function receives a copy of


the value of the arguments, rather than their original reference. This approach allows
the function to access but doesn’t allow to modify the original variables, which can
enhance the protection of data of programs.

Example

void calculate (int no1, int no2) {

no1 = no1 * 1.5;


no2 = no2 * 2;

int newValue = no1 + no2;

cout << "New value " << newValue << endl;


}

void main() {

int x = 10;
int y = 5;

cout << "x " << x<< endl;


cout << "y " << y<< endl;

calculate(x, y);

cout << "x " << x<< endl;


cout << "y" << y<< endl;
}
In the above example, the original values of x and y will not change.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Modular Programming
This resource explores modular programming, a method of designing software by
breaking down functions into independent modules. It emphasises grouping lines of
code into functions, which can be either for program control or specific tasks.

Modular Programming

Reference: Busbee K.L. & Braunschweig D 2024, Modular Programming, rebus Community (online
publication), accessed 18 January 2024,
<https://press.rebus.community/programmingfundamentals/chapter/modular-programming/>

Reading: Modular Programming - Organising Code with Functions


Breaking a complex problem into smaller and more manageable parts is a common
practice. We call each of these parts of a program a module and the process of
subdividing a problem into manageable parts top-down design. This article explores
the principles of top-down design and structured programming.

Organizing Code with Functions

Reference: n.d., 'Organizing Code with Functions', accessed 31 January 2024,


<https://sites.google.com/view/sirallan-programmingtutorials/modular-programming-organizing-code-
with-functions>

Reading: Modularization and C++ Program Layout


This article discusses the concept of modularization in programming, focusing on
C++. It emphasizes the importance of grouping lines of code into units called
functions, which can be included in a program. Functions are categorized into
Program Control (unique to the program being written) and Specific Task (designed
for use in multiple programs).

Modularization and C++ Program Layout

Reference: Kenneth Leroy Busbee n.d., 'Modularization and C++ Program Layout', LibreTexts,
accessed 31 January 2024,
<https://eng.libretexts.org/Bookshelves/Computer_Science/Programming_and_Computation_Fundam
entals/Programming_Fundamentals_-_A_Modular_Structured_Approach_using_C_(Busbee)/02%3A_
Introduction_to_Programming/2.03%3A_Modularization_and_C_Program_Layout>

Reading: Pass-by-value vs Pass-by-reference with C++ examples


This article explains how functions handle values when called in programming. When
calling a function, values can be passed either by value or by reference. The article
includes simple code examples for both pass-by-value and pass-by-reference,
clarifying the concepts with code and comments.

Pass-by-value vs Pass-by-reference — with C++ examples

Reference: Karimov I 2020, Pass-by-value vs Pass-by-reference — with C++ examples, Medium


(website), accessed 18 January 2024,
<https://medium.com/star-gazers/pass-by-value-vs-pass-by-reference-with-c-examples-911e7e81ae6
5>
Module 6. Modular Programming and Algorithms Pt.
2
In the previous module, we discussed the practice of modular programming and
standard algorithms being central to efficient coding and software development. This
module introduces more principles of modular programming.

You've learned that functions let you reuse blocks of code numerous times, saving
you from having to repeat lots of code. This module looks at Header files that work
similarly, allowing you to reuse entire files that include any number of functions. They
let you separate programs into several files and allow you to use the code of one file
in another file.

You will also learn about a fundamental data type of C++, the string. You previously
learned how to store your name and other words in arrays of characters. This is
done so frequently that C++ has a data type that will handle all the complexity for
you, and allow operations of words such as adding (concatenating) words together to
form a sentence.

In this module, you will explore:

● Learn further about the modular programming approach, breaking down


complex programs into manageable and reusable modules or functions.
● Gain insights into pass-by-reference parameter passing, and how it affects
the calling variables.
● Gain insights about C++ header files and its usage
● Gain insights about C++ strings and its usage

To enhance your understanding, we have tailored specific learning activities:

● Write a function that uses pass-by-value and demonstrates its effect on


the caller's variables.
● Write a program to calculate the area of a triangle, using Header Files and
Built-in Libraries.
● Write a program to implement an algorithm that reads in a sentence and
search string. Then count the occurrences of the search string within the
sentence.

Subject Learning Outcomes


The material in this module relates to the following subject learning outcomes:

​ SLO 3: Learn to implement complex data structures like stacks, queues,


trees, and graphs, as well as algorithms for sorting and searching.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 3. Pass-by-Reference Parameter Passing

Key takeaways from this topic...


1. Pass-by-reference allows a function to modify the caller's variables directly,
facilitating data manipulation without creating a copy.
2. Using pass-by-reference can save memory, as it avoids creating copies of
large data structures.
3. While pass-by-reference is powerful, it can also introduce errors if not used
carefully, as changes to the variable within the function affect its original value.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Pass-By-Reference and Its Comparison with


Pass-By-Value

In programming, particularly in languages such as C++, parameter passing is a


technique where you provide inputs to functions. There are several methods to pass
parameters, and one of the most commonly used methods is "pass-by-reference".
This method not only facilitates the efficient use of memory but also allows the
function to modify the original data.

Understanding Pass-By-Reference
Pass-by-reference is a parameter passing method where a function receives the
reference or memory address of the arguments, rather than their values. This
approach allows the function to access and modify the original variables, which can
enhance the functionality and efficiency of programs. Key features of this method
include:

● Memory Efficiency: Since only the memory address is passed, it prevents


duplication and saves memory space.
● Data Modification: Functions can alter the original data as they have
access to the memory address where the data is stored.
● Complex Data Handling: It is beneficial when working with complex data
structures, as it avoids the overhead of copying large amounts of data.

Comparison with Pass-By-Value

Understanding pass-by-reference becomes clearer when compared with


pass-by-value, another prevalent parameter passing method. In the pass-by-value
approach, a copy of the data is passed to the function, and any modifications made
inside the function do not affect the original data. The comparison between the two
methods can be summarised as follows:

● Memory Usage: Pass-by-reference is more memory-efficient as it avoids


data duplication, unlike pass-by-value where a copy of data is created.
● Data Alteration: In pass-by-value, the original data remains unaffected by
the function's operations, whereas pass-by-reference allows for direct
modification of the original data.
● Use Cases: Pass-by-value is suitable for smaller data sets or when you
want to ensure the original data is not modified. On the other hand,
pass-by-reference is ideal for larger data sets and when modification of
the original data is necessary.

Further Reading

Parameter Passing in C++


Links to an external site.

Explore these methods of parameter passing with code examples.

Reference: Geeks for Geeks 2023, 'Parameter Passing in C++', Geeks for Geeks, accessed 31
January 2024, <https://www.geeksforgeeks.org/parameter-passing-techniques-in-cpp/>

Section 2: Real-World Applications of Pass-By-Reference

Real-world scenarios witness a significant application of pass-by-reference


parameter passing, showcasing its efficiency and utility. Here are some of the
applications where this concept is predominantly applied:

● Database Management: In systems where large databases are handled,


pass-by-reference assists in efficient memory management, facilitating
quicker data retrieval and modification.
● Gaming Industry: Game developers use this method to efficiently manage
and modify game states without incurring the overhead of copying large
data sets.
● Simulation Software: In simulations where real-time data modification is
essential, pass-by-reference enables seamless data updates, providing
accurate and timely results.

Section 3: Case Study: Enhancing Performance in a Financial Analytics Tool


Background

In the competitive financial sector, analytics tools play a pivotal role in facilitating
data-driven decisions. A leading financial analytics firm was grappling with
performance bottlenecks in their flagship tool, which was primarily attributed to the
existing method of pass-by-value parameter passing. This method was causing
delays, particularly during real-time data analysis phases, leading to high memory
consumption and consequently, slower processing times.

Objective

The primary objective was to augment the tool's performance by reducing memory
consumption, thus facilitating more efficient real-time data modification capabilities.
The aim was to revamp the system's core functionalities to streamline processes,
reduce latency, and offer more accurate and timely insights to their clients.

Implementation

To address the issue, the firm initiated a comprehensive analysis to pinpoint the
exact causes of the delays. It was decided to shift from the current pass-by-value
parameter passing method to a more efficient pass-by-reference parameter passing
technique. This shift involved significant changes in the coding structure and data
handling processes within the tool. Key strategies implemented included:

● Algorithm Optimisation: The development team worked meticulously to


optimize the existing algorithms, enhancing their performance and
reducing computational complexity.
● Memory Management: The new method facilitated better memory
management by eliminating the need to create multiple data copies,
thereby saving considerable memory space.
● Real-Time Data Modification: With the shift to pass-by-reference
parameter passing, the tool was now capable of conducting real-time data
modifications, which enhanced the accuracy and speed of financial
analyses.
● Testing and Deployment: Before fully integrating the changes, extensive
testing was conducted to ensure the stability and reliability of the updated
tool.

Outcome

Post-implementation, the tool demonstrated a significant improvement in


performance. It could now offer quicker data analyses and facilitate real-time
modifications. Clients noted a marked improvement in the speed and accuracy of the
analytics provided, fulfilling their needs for more precise and timely financial insights.

Furthermore, the transition led to an increase in client satisfaction levels, as they


could now make data-driven decisions faster, giving them a competitive edge in the
fast-paced financial sector.

Topic 2. Header Files and Built-in Libraries

Key takeaways from this topic...


1. Header files in C++ are used to declare functions, classes, and variables,
allowing code to be modular and reusable across different source files.
2. The #include directive is used to include header files in a C++ program,
enabling access to the declarations and definitions contained within them.
3. C++ provides standard header files (like <iostream> and <cmath>) for
built-in functionalities, while programmers can also create user-defined
header files to encapsulate their own functions and classes.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Header Files and Built-in Libraries

In this topic, you will learn how to create, modify, and use Header files. You will then
learn about libraries of functions that you can use within your program, by including a
header file, which lets you use decades of work by incredible programmers to help
you solve common problems in your own programs. You will learn about common
libraries such as the C math library and C type library.

What are header files?


Header files contain declarations, including function declarations, which can be used
in our main C++ program. For example, iostream is included in our main program to
use cout to print something to the console window.

Header files usually have a .h extension by convention. We can use as many header
files in our program as we like, and we can define our own.

Header files allow us to use existing functions already defined and tested by other
programmers. One programming principle is to avoid ‘recreating the wheel’. In other
words, if someone has already done it and it works well and is used by many, there
is no reason not to use it yourself.

They are necessary as our programs become larger.

Why the concern about large programs?

A large .cpp file increases the compile time. As our program gets bigger we will have
more lines of code, and if everything is in a single file, then everything must be
recompiled every time you make a change.

It keeps our code more organised. If you separate concepts into specific files, it is
easier to find the code you are looking for when you are making modifications. The
biggest source of bugs in code is caused by code that is hard to understand because
it is poorly organised.

Header files and libraries

Header files declare the functions implemented in a library.

○ Include in your program to use those functions.


○ Contents of header files are added to your source.cpp during
preprocessing.
Libraries contain the function implementations.

○ Separately compiled.
○ Automatically or manually linked by the compiler when your
source code is built.

Types of header files in C++

● Standard built-in header files


○ Provide basic function declarations.
○ Implemented with installed libraries.
○ Libraries are automatically linked by the compiler.
○ Examples, iostream, iomanip, etc...
● User header files
○ Functions that are not included in a built-in library.
○ Associated libraries must be manually linked during compilation.
○ Anyone can create and provide functions for others to use.

Standard built-in header files

Example

#include <iostream>

using namespace std;

int main()
{
cout << "hello, world!" << endl;
return 0;
}
This example program prints “Hello, world!” to the console window using cout. This
program does not have any definition or declaration about the cout, so how does the
compiler know about it?

The answer is, cout has been forward declared in the iostream header file.

When we use #include <iostream> we are requesting the preprocessor to copy all
the contents of iostream from the file named “iostream” into our source.cpp.

Topic 3. Strings

Key takeaways from this topic...

1. In C++, strings are represented as sequences of characters and can be


handled using the standard library's std::string class for easier
manipulation compared to character arrays.
2. C++ provides a variety of built-in functions for string manipulation, including
concatenation, substring extraction, and searching, making it simple to work
with text data.
3. While std::string is commonly used, strings can also be represented as
character arrays, which require careful management of memory and
null-terminators to indicate the end of the string.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All
Panels

Collapse All

Panels

Section 1: Strings

Strings are handily provided to us in a library that we can include in our project via a
header file, another great example of a library we can use in our project that saves
us having to write our own functions!

During the lectures, you will learn about all the operations that we would want to
perform on a string, such as changing out letters in a string, comparing two strings to
see if they are the same, adding characters to the end of a string, and much more.

By using strings we can quickly change the data within a string, such as adding new
words to a string or replacing words in a string, for example, we could turn the string
from “Happy” to “Happy Birthday!” or “Happy Holidays!” by simply adding two words
to a string.

C-strings

C-strings, or character strings, are arrays of characters in C++ that end with a null
terminator (\0), which indicates the end of the string. Unlike the std::string
class, C-strings require manual memory management and careful handling to avoid
overflow and other issues. While they can be used for string manipulation, they often
involve more complex syntax and functions from the C standard library, such as
strlen() for length and strcpy() for copying.

Example:

char name[] = "Susan";


One dimensional array of characters which is terminated by a null character ‘\0'. C++
supports a wide range of functions that manipulate null-terminated strings.

Operations on character arrays <cstring>

Function Description

strcpy(s1, s2) Copies string s2 to s1.

strcat(s1, s2) Concatenates string s2 onto the end of


string s1.

strlen(s1) Returns the length of the string.

strcmp(s1, s2) ● Returns 0 if s1 and s2 are the


same;
● Less than 0 if s1 appears before
s2 in lexical order;
● Greater than 0 if s1 appears
after s2 in lexical order

https://docs.microsoft.com/en-us/cpp/standard-library/cstring
Links to an external site.

The String class

C++ Library - <cstring>

The standard C++ library provides a string class type that can be used for storing
text, such as “hello” or “My name is Tom!”.

String objects are dynamic, unlike character arrays, strings are not fixed.

The size of a string grows and shrinks when its contents change.

A string variable contains a collection of characters surrounded by double quotes.

https://en.cppreference.com/w/cpp/string/basic_string

Links to an external site.

Using the string class

To use strings, we must include an additional header file in the source code.

#include <cstring>

Create a variable of type string and assign the value enclosed in double quotes:
string message = "Hello";

We should also include using namespace std; to make the short name string visible
instead of std::string.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Pass-by-value vs Pass-by-reference — with C++ examples
This article explains how functions handle values when called in programming. When
calling a function, values can be passed either by value or by reference. The article
includes simple code examples for both pass-by-value and pass-by-reference,
clarifying the concepts with code and comments.

Pass-by-value vs Pass-by-reference — with C++ examples

Reference: Karimov I 2020, Pass-by-value vs Pass-by-reference — with C++ examples, Medium


(website), accessed 18 January 2024,
<https://medium.com/star-gazers/pass-by-value-vs-pass-by-reference-with-c-examples-911e7e81ae6
5>

Video: Header Files - C++ Tutorial For Beginners


The video explains the purpose and structure of header files in C++, emphasising
their role in organising code and separating function declarations from
implementations to enhance clarity and encapsulation. It demonstrates how to create
header files, include them in source files, and compile multiple files to maintain
modularity in larger applications.

Header Files - C++ Tutorial For Beginners

Links to an external site.

(09:39)
Reference: NeuralNine (2020) 'Header Files - C++ Tutorial For Beginners', YouTube [online video]
<https://www.youtube.com/watch?v=0TCh01BBlrM> Accessed 16 Sept. 2024

Video: Strings - C++ Tutorial For Beginners


This C++ programming tutorial provides an introduction to handling strings in C++,
differentiating between C-style strings and C++ string objects. It covers the creation
and manipulation of strings, including essential functions like strcpy, strcmp, and
strcat, while also discussing the security risks associated with using C strings, such
as buffer overflow vulnerabilities. The tutorial explains the advantages of using the
std::string class in C++, highlighting its ease of use, built-in methods for length and
comparison, and safer memory management.

Strings - C++ Tutorial For Beginners

Links to an external site.

(19:10)

Reference: NeuralNine, 2020, 'Strings - C++ Tutorial For Beginners', YouTube [online video]
<https://www.youtube.com/watch?v=zo6B_eJmeLo> Accessed 16 Sept. 2024
Module 7. Tools and Techniques for Debugging I
Debugging is an essential skill for software developers, providing the means to find
and fix errors in code. With the right tools and techniques, debugging can be a
smooth process that enhances the efficiency and quality of a program. This module
offers a comprehensive look at integrated development environments (IDEs),
stand-alone debugging tools, and tracing code execution.

In this module, you will explore:

● Understand what IDEs are and how they facilitate software development,
including setting up and exploring an IDE through practical applications.
● Learn about various stand-alone debugging tools and how to use them
effectively, focusing on techniques like breakpoints and stepping-through
functions.
● Delve into tracing techniques that assist in debugging, such as using
"Assert," "Print," and "Stop."

To enhance your understanding, we have tailored specific learning activities:

● Setting up and exploring an IDE through a basic "Add Student" application


● Utilising debugging tools to set breakpoints, step into and over functions
● Implementing tracing techniques like "Assert," "Print," and "Stop" for
debugging

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 5: Gain hands-on experience with debugging through various tools,


including IDEs, and understand how to set breakpoints, inspect variables,
and trace code execution.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Introduction to Integrated Development


Environments (IDEs)

Key takeaways from this topic...

1. IDEs provide an all-in-one environment for coding, debugging, and testing,


streamlining the development process.
2. Many IDEs come with powerful features like code completion, version control
integration, and built-in debugging tools.
3. IDEs are often highly customisable, allowing developers to tweak the
environment according to their workflow and preferences.

Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Introduction to Integrated Development Environments (IDEs)

An IDE is a powerful software suite that combines various features and utilities to
facilitate the seamless development of software applications. Essentially, it is a
one-stop solution that aids programmers in writing, testing, and deploying code more
efficiently, effectively shortening the development cycle and enhancing productivity.

Catering to Diverse Developer Needs

IDEs cater to a broad spectrum of developers, from novices to seasoned


professionals. For beginners, IDEs provide a supportive environment where they can
learn coding principles without getting bogged down by the complexities of setup and
configuration.

For experienced developers, the extensive features and customisation options


available in IDEs enable them to work at peak efficiency, tailoring the environment to
suit their specific project requirements.

The Impact on Modern Programming

Today, IDEs are central to the software development landscape. They have not only
simplified coding but also fostered collaboration and innovation, allowing teams to
work cohesively and leverage each other's expertise to build complex and
sophisticated software solutions. Through features like debugging, code completion,
and collaboration tools, IDEs have truly transformed the way programmers approach
software development.

Section 2: Core Features and Customisation Opportunities within IDEs

Explore the core functionalities of an IDE and understand the diverse customisation
opportunities that they offer to cater to individual project needs.

Features of an IDE

a. Text Editor: A central feature that facilitates code writing.


b. Compiler: This utility translates your written script into a format ready for
execution.
c. Debugger: A critical feature to help identify and correct errors in your code.
d. Auto-completion: Proposes code suggestions as you type, expediting the
coding process.
e. Syntax Highlighting: Differentiates elements of the code through coloured
text, enhancing readability and comprehension.
Customisation and Extensions

Most IDEs provide extensive personalisation options, allowing for the addition of
extensions that support different languages, debuggers, or version control systems.
For example, Visual Studio Code maintains a marketplace for a variety of extensions
to accommodate diverse needs.

Advanced Utilities and Collaborative Features

● Integrated Terminal
An attribute that optimises your workflow by enabling shell commands
execution directly within the IDE.
● Code Profiling
Certain IDEs offer built-in tools for measuring various metrics such as
memory usage and CPU consumption.
● Database Management
Some IDEs incorporate features for executing SQL queries and managing
databases directly within the platform.
● Dependency Management
Facilitates easy addition, update, or removal of external libraries that your
project relies upon.
● Code Review Tools
These facilitate team members to comment on each other’s code, propose
changes, and merge pull requests directly within the IDE.
● Support for Multiple Languages
Most IDEs are versatile, offering support for a range of programming
languages.
● Collaboration Features
Modern IDEs come equipped with features to foster team collaboration,
including functionalities like pair programming, code sharing, and real-time
coding sessions. Visual Studio, for instance, hosts a feature named “Live
Share” for this purpose.

Further Reading
What is an IDE?

Links to an external site.

Explore the IDE concept further and discover the different types such as Desktop
IDEs, Cloud IDEs, Mobile App Development IDEs, and Database-Specific IDEs.
Learn how to choose an IDE based on factors like programming language, operating
system, pricing model, and features.

Reference: Geeks for Geeks, n.d., 'What is an IDE?', Geeks for Geeks, accessed 31 January 2024,
<https://www.geeksforgeeks.org/what-is-ide/>

Section 3: Case Study - Leveraging Integrated Tools for Scientific Research

In this case study, we examine a real-world scenario where a team of data scientists
at a prominent research institution leveraged the power of an Integrated
Development Environment (IDE) to streamline their research process and enhance
the quality of their work.

Scenario

A group of data scientists were tasked with developing complex machine learning
models to analyse vast datasets for a critical research project. The team faced
challenges in managing code, data, and computational resources efficiently, with
their workflow involving coding, data analysis, and version control.

The Selection of JupyterLab

To address these challenges, the team opted for JupyterLab, a web-based IDE
specifically tailored for scientific computing and data science workflows. JupyterLab
offers an integrated environment that encompasses text editors, terminals, data file
viewers, and other tools essential for data analysis and scientific computing.

Implementation and Workflow

With JupyterLab, the team could centralise all their tools and resources in one place.
They were able to write code, perform data analysis, and manage version control, all
within a single platform. The following features of JupyterLab were particularly
beneficial:

1. Interactive Computing
The team could create and share documents that contained live code,
equations, visualizations, and narrative text, fostering collaborative analysis
and data exploration.
2. Extensibility
JupyterLab offered the team the flexibility to customize and extend their
environment with additional tools and features, aligning with the specific
requirements of their project.
3. Integrated Tools for Data Visualisation
The IDE provided powerful tools for data visualisation, enabling the team to
generate insightful graphs and charts that facilitated data interpretation and
reporting.
4. Version Control
JupyterLab's integration with version control systems allowed the team to
manage changes to their codebase efficiently, tracking revisions and
maintaining a history of modifications.
Outcome

The implementation of JupyterLab dramatically improved the team's overall


productivity and research quality. The centralised, integrated environment facilitated
smoother collaboration and communication among team members, enabling them to
work more cohesively and achieve their project objectives with increased efficiency
and effectiveness.

Moreover, the platform's user-friendly interface and powerful tools for data analysis
and visualisation helped the team to glean more insightful findings from their data,
contributing to the success of their research project.

Topic 2. Using Stand-Alone Debugging Tools

Key takeaways from this topic...

1. Stand-alone debugging tools can offer specialised features not found in IDEs,
making them useful for targeted debugging scenarios.
2. Features like setting breakpoints and stepping into/over functions are
essential for thorough debugging.
3. Some stand-alone debugging tools work across multiple platforms and
languages, offering more flexibility.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All
Panels

Collapse All

Panels

Section 1: Stand-Alone Debugging Tools

Debugging is an essential step in the software development process, where errors or


"bugs" in the code are identified and rectified. While IDEs often incorporate
debugging tools, at times, stand-alone debugging tools become indispensable. This
section provides a guide to these tools, highlighting their types and benefits.

What are Stand-Alone Debugging Tools?

These are specialised tools designed to function independently from an IDE, offering
functionalities like code inspection, breakpoint management, and sometimes reverse
engineering capabilities. These tools are versatile and can provide deep analysis
and insights into your code’s behavior, often more than what's possible with an
integrated debugger.

Popular Debugging Tools

1. GDB
2. Links to an external site.
3. (GNU Debugger)
A popular open-source debugger, accommodating numerous languages
including C and C++.

4. WinDbg
5. Links to an external site.
6.
A comprehensive debugger for Windows, facilitating both kernel-mode and
user-mode debugging.

7. Fiddler
8. Links to an external site.
9.
Predominantly used to debug HTTP transactions.

10. Wireshark
11. Links to an external site.
12.
A tool focused on network debugging, it captures and analyses network
packets.

13. Valgrind
14. Links to an external site.
15.
This tool is significant for memory debugging, leak detection, and profiling.

Section 2: Advantages and Usage of Stand-Alone Debugging Tools

Why Use Stand-Alone Debugging Tools?

Utilising stand-alone debugging tools presents several benefits, including advanced


features not found in IDEs, resource efficiency, flexibility, and the capacity for deeper
analysis, assisting in achieving a more detailed insight into your project.

How to Use Stand-Alone Debugging Tools


Understanding how to use these tools effectively can enhance your debugging skills
considerably. The process includes:

1. Installation
Download and set up the tool compatible with your OS and programming
language.
2. Code Configuration
Adjust your code to be debug-ready, typically by including debugging
information during compilation.
3. Launching the Debugger
Load your code into the opened debugger.
4. Setting Breakpoints
Establish points in the code where you wish to pause for inspection.
5. Start Debugging
Execute the debugger, which will run your code until a breakpoint is reached,
facilitating variable, memory, and CPU registers inspection.
6. Step Through Code
Further execute your code step-by-step to comprehend its behaviour in
various scenarios.

Further Reading

Debugging: A Basic Beginner's Guide

Links to an external site.

Further explore the intricacies and considerations of debugging in software


development and learn various debugging tools and techniques, including
debuggers, profilers, logging and tracing tools, memory debuggers, code analysis
tools, and unit testing frameworks.

Reference: Sonar staff, n.d. 'debugging: basic beginner's guide', Sonar, accessed 31 January 2024,
<https://www.sonarsource.com/learn/debugging/>
Section 3: Case Study - Debugging Memory Leaks in a Web Application

Background

In the fast-paced world of web development, a team is working tirelessly on a


complex web application designed to streamline business processes for a growing
company. As they approach the deployment phase, they encounter a persistent
issue: a memory leak that seems to be slowing down the application significantly.
The issue has started to affect the performance and stability of the application,
causing occasional crashes which were threatening to delay the project timeline.

Scenario

Despite having used the debugging functionalities integrated into their preferred IDE,
the team has struggled to pinpoint the source of the memory leak. The intermittent
nature of the issue and the vast codebase were making it increasingly difficult to
locate the exact point where the leak was occurring. The clock was ticking, and the
pressure to resolve the issue promptly was mounting.
Decision to Use Valgrind

Realising that a more specialised approach was needed, the team decided to utilise
Valgrind, a renowned stand-alone debugging tool. Valgrind is well-regarded in the
industry for its ability to provide detailed insights into memory usage and potential
leaks, often outperforming integrated debugging tools in this aspect.

Implementation and Process

The team initiated the process by configuring their codebase to include detailed
debugging information, making it compatible with Valgrind's analysis tools. After
setting up Valgrind, they ran the application through various scenarios, with Valgrind
monitoring the memory allocations and deallocations happening in the background.

Valgrind's memory error detector, Memcheck, proved to be particularly beneficial. It


helped the team to monitor the memory usage in real-time, flagging potential areas
of concern. The tool was able to point to the exact lines of code where memory
allocations were not being properly deallocated, leading to the memory leak.

Solution and Outcome

After a series of rigorous sessions with Valgrind, the team successfully identified the
issue: a complex data structure was not being cleared properly, leading to gradual
memory buildup over time. Armed with this detailed information, they were able to
address the issue at its root, optimizing the code to prevent memory leaks and
improving the overall stability of the application.

Now, the application ran smoother, with significantly reduced chances of crashes due
to memory leaks. The team also documented their experience with Valgrind, creating
a guideline for leveraging stand-alone debugging tools for future projects, fostering a
culture of continuous learning and adaptation.
Topic 3. Tracing Code Execution

Key takeaways from this topic...

1. Tracing techniques such as assert, print, and stop provide real-time insights
into how the code is being executed.
2. Tracing is invaluable for quickly identifying the origins of errors or unexpected
behaviours in code.
3. Some tracing methods allow for conditional monitoring, executing only when
specific conditions are met, thus providing focused debugging.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding Tracing Code Execution

What is Tracing Code Execution?


Tracing is essentially following the path that a program takes during its execution. It
allows you to see the order in which functions are called, where variables change
their values, and what output is generated at each step.

Methods for Tracing Code Execution

● Manual Tracing
Involves going through the code line-by-line manually, keeping track of
variables and flow of execution.
● Print Statements
Inserting print statements at key points to display the current state or value
of variables.
● Built-in Debuggers in IDEs
These allow you to pause execution, step through code one line at a time,
inspect the state, and even change variables in mid-execution.
● Profiling Tools
Specialised tools that offer in-depth statistics about resource consumption
of functions.
● Tracing Software
Designed to track the execution of code and report back in various
formats.

Section 2: Implementing Tracing

In this section, we delve deeper into each method of tracing code execution,
providing a comprehensive guide on how to use them effectively, alongside their
advantages and disadvantages.

Manual Tracing

Manual tracing is a fundamental method where developers follow the flow of


execution by inspecting each line of code manually.
How to Use
Begin by displaying the code on screen or taking a printout. Use a pen or a cursor to
trace each line, jotting down the state of variables at each step, which helps in
keeping track of the program’s progression.

Advantages
It’s a straightforward method that doesn’t require any additional tools, providing a
raw understanding of the code's flow.

Disadvantages
Can be quite time-consuming and prone to human error, especially for complex code
with numerous lines and functions.

Print Statements

This technique involves inserting print statements at key points in the code to
monitor the state or value of variables as the program runs.

How to Use
Depending on the programming language, use functions like print() in Python or
System.out.println() in Java to insert messages that will display the current
state at various stages in the code.

Advantages
It offers a quick way to monitor the code’s behaviour in real-time.

Disadvantages
Can clutter the code, making it less readable, and may not provide in-depth
information for complex debugging scenarios.

Built-in Debuggers in IDEs


Most Integrated Development Environments (IDEs) offer built-in debuggers that
allow developers to comprehensively inspect the flow of code execution.

How to Use
Configure the debugger in your IDE and set breakpoints at critical points in the code.
Once the debugger is running, you can inspect variables and the flow of execution
as it hits these breakpoints. Additionally, you have the flexibility to modify variables
during runtime to test different scenarios.

Advantages
These debuggers are powerful, offering extensive features that facilitate a deep
analysis of code behaviour.

Disadvantages
May have a steep learning curve, particularly for beginners, and integrating them into
the workflow can sometimes be complex.

Profiling Tools

Profiling tools are specialised utilities that provide detailed statistics on the resource
consumption of various functions in your code, helping to identify bottlenecks and
optimize performance.

How to Use
Run these tools alongside your code. They generate a report outlining aspects like
time-consuming functions and memory usage, offering insights into the areas where
optimisation is necessary.

Advantages
These are excellent resources for optimising code, providing deep insights into the
performance characteristics of your application.
Disadvantages
While great for performance optimisation, they might not be the best tools for
identifying logic errors or understanding complex algorithmic flows.

Tracing Software

Tracing software is designed to meticulously track the execution of code and report
the findings in different formats, offering real-time insights into the program’s
behaviour.

How to Use
Integrate the software into your development environment and run your code through
it. These tools provide a detailed trace of the execution, offering insights that can be
invaluable in debugging complex issues.

Advantages
Can provide real-time insights and comprehensive data about code execution,
facilitating deep analysis and understanding of code behaviour.

Disadvantages
May be an overkill for simple projects and can sometimes introduce a performance
overhead.

Further Reading

Tracing Code in C++

Links to an external site.


Learn more about tracing code in C++ for real-time insights and deep analysis of
code behaviour using tracing software.

Reference: Josh Weinstein 2020, 'Tracing Code in C++', Medium, accessed 31 January 2024,
<https://medium.com/swlh/tracing-code-in-c-fd9470e3bf5>

Section 3: Case Study - Debugging a Shopping Cart Issue Through Tracing

Identifying the Issue

Faced with a recurrent problem where items would mysteriously vanish from
customers' shopping carts, causing annoyance and a potential drop in sales, the
development team needed to pinpoint the underlying issue. The problem seemed
random and elusive, making the traditional approaches ineffective in diagnosing the
root cause.

Choosing Debugging Methods

To navigate this complex scenario, the team planned a meticulous approach by


combining various tracing code execution techniques:
● Print Statements
The team embedded print statements strategically within the code,
enabling real-time tracking of the shopping cart's status during various
critical stages, such as adding or removing items and initiating the
checkout process.
● IDE Debugging
Simultaneously, the powerful debugging features in their IDE were
employed to scrutinise variable states and logic flow at distinct
breakpoints, offering deeper insights into the code's functioning at pivotal
junctions.

Gathering Data

The data collection phase witnessed intensive efforts:

● Print Statements Data


This method recorded dynamic changes to the shopping cart's status.
These outputs illustrated the current items and their quantities at different
phases, painting a detailed picture of the cart's transitions.
● IDE Debugging Insights
The IDE debugger allowed the team to halt the code temporarily at
specific points, facilitating a deeper investigation into the states of various
variables and how the shopping cart's state was being altered during the
process.

Uncovering the Culprit

After numerous debugging sessions, the team unearthed the core of the problem: a
malfunction within the updateCart() function. This function, meant to adjust the
shopping cart's status when an item's quantity was altered, harboured a bug that
removed items under specific conditions - notably, when a customer had more than
five items in the cart and chose to modify the quantity of any item.
Implementing the Solution

Having identified the problem, the team embarked on a mission to rectify it:

● Modifying the UpdateCart() Function


The team reworked the function to handle all scenarios appropriately,
thereby preserving the shopping cart's stability during all operations.
● Testing the Solution
An extensive battery of tests was conducted before deploying the fixed
function, to ensure a fluid and error-free shopping experience for the
customers.

Outcome

The rigorous approach and the synergistic use of multiple debugging methods
yielded results, and the disappearing items issue was finally resolved. The proactive
response not only ensured a smoother user experience but also potentially saved
the business from significant revenue losses. This episode fortified the team's
confidence in the power of detailed code tracing and showcased how a multifaceted
approach could effectively untangle even the most perplexing issues in software
development.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: C/C++ Debugging Tools
This article provides an overview of various debugging tools available for C/C++
applications. It covers different aspects of debugging, starting with the importance of
automated testing, including Test-Driven Development and unit test frameworks like
QTestLib, Google Test, and Catch.

C/C++ Debugging Tools

Links to an external site.

Reference: David Faure, 2022, 'C/C++ Debugging Tools', KDAB [online] url:
https://www.kdab.com/c-cpp-debugging-tools/ [Accessed 31 Jan. 2024]

Reading: Top Tips for Debugging C++


This article features Greg Law, the co-founder and CEO at Undo, sharing essential
debugging tips for C++ developers. His tips cover a range of topics, including the
importance of having a comprehensive set of debugging tools, utilizing conditional
breakpoints for efficient debugging, using watchpoints to track changes in variable
values, enhancing variable printing with pretty-printers, exploring Time Travel
Debugging to analyse program execution history, and utilising the find command in
GDB to search for specific byte sequences in memory.

Top Tips for Debugging C++

Links to an external site.

Reference: Anastasia Kazakova & Greg Law, 2021, 'Top Tips for Debugging C++', Jet Brains [online]
url: https://blog.jetbrains.com/clion/2021/06/7-top-tips-for-debugging-cpp/ [Accessed 31 Jan. 2024]

Video: A Guide to Debugging C++ Code - Practical Examples


We like to write code but—despite our best efforts—we make mistakes. Our program
will contain bugs. Sometimes, we don’t write what we mean to write, sometimes we
don’t understand an aspect of our programming language and at other times we
lack—or fail to consider—some critical information about our program’s system
environment. As a result, our program will not behave correctly. What do we do now?

In this talk, experienced developer Sebastian Theophil takes you through the entire
debugging process, starting with a program that crashes. What do we do next?
Which questions do we have to ask? What information do we need? What can we do
to find the cause of the crash? Which tools can help us in this quest, and, last but not
least, what can we do to make sure this bug never happens again?

A Guide to Debugging C++

Links to an external site.

(44:22)
Reference: Sebastian Theophil, 2023, 'A Guide to Debugging C++ Code: Practical and Interactive
Examples', YouTube [online video] url: https://youtu.be/Rc2hFf1HVow [Accessed 19 Jan, 2024]

Video: Back to Basics - Debugging in C++


In this talk from CppCon 2022, Mike Shah shows you how to debug C++ code,
starting from the very basics and then demonstrating how a debugger like GDB can
be used to help you track errors in CPU code. Learn about debugging techniques
(e.g. delta debugging), and several debugging tools (stepping through code,
capturing backtraces, conditional breakpoints, scripting, and even time traveling!).

Back to Basics: Debugging in C++

Links to an external site.

Reference: Mike Shah, 2022, 'Back to Basics: Debugging in C++', YouTube [online video] url:
https://youtu.be/YzIBwqWC6EM [Accessed 19 Jan. 2024]

Video: GDB Debugging - How to Debug a C/C++ Program


GDB is a powerful debugger that allows us to work with C/C++ code from inside the
operating system terminal. Mastering GDB will help you evolve as a programmer and
open doors to optimize your code and find potential errors.

This video explains what the GDB debugger can do, walking you through executing
the GDB tool step-by-step to demonstrate the most common commands to add
breakpoints, watch variables, and pause/resume the execution of C++ code.

GDB Debugging

Links to an external site.

(18:07)

Reference: pikuma, 2019, 'GDB Debugging: How to Debug a C/C++ program', YouTube [online video]
url: https://youtu.be/gFCQ37jVN3g [Accessed 19 Jan. 2024]

Reading: Debugging without an IDE - Using GDB


Debugging is clearly an important skill for any programmer in any language, with
C++ probably requiring better debugging skills than most popular languages, due to
its relative complexity. What’s more, the actual problems we solve with C++ tend to
be more complex, which may bring about unexpected results that require analysis
and debugging.
This post provides a step-by-step demonstration intended to teach just enough to
allow any programmer to debug code on the terminal alone, and to do so with more
ease than you may have thought possible.

Debugging without an IDE

Links to an external site.

Reference: Joseph Sibony, 2022, 'A Step-by-step Crash Course in C++ Debugging without IDE –
Empowering the terminal by using GDB', Incredibuild blog [online] url:
https://www.incredibuild.com/blog/a-step-by-step-crash-course-in-c-debugging-without-ide [Accessed
31 Jan. 2024]

Resources: Debugging C++ Code using Visual Studio


Following are a series of readings and videos that explain and demonstrate the
debugging features and abilities of Visual Studio.

● Learn to Debug C++ Code using Visual Studio (2022)


● Links to an external site.
● - Microsoft VS 2022 documentation
● Basic Debugging in Visual Studio (2024)
● Links to an external site.
● - LinkedIn Learning video (04:12)
● Visual Studio: Advanced Debugging Tools (2020)
● Links to an external site.
● - LinkedIn Learning course (2.5hrs)
● New Debugger Features in Visual Studio 2022
● Links to an external site.
● - video (09:47)
Module 8. Debugging - Part 2
Debugging is not just about finding errors; it also involves examining variable
contents, implementing logging frameworks, and creating custom event logs.
Building on the fundamentals of debugging, this module delves deeper into
advanced debugging techniques that are crucial for efficient software development.

In this module, you will explore:

● Master how to use IDE tools to inspect variable values during code
execution, providing insights into how your code is functioning.
● Learn how to integrate logging and error handling into applications, such
as tracking success and failure events, using modern frameworks and
best practices.
● Explore how to create custom event logs and view them in Windows Event
Viewer, complete with specific messages for success and failure.

To enhance your understanding, we have tailored specific learning activities:

● Using IDE tools to inspect variable values during code execution.


● Integrating logging and error handling into the "Add Student" Application,
including success and failure events.
● Creating custom event logs and viewing them in Windows Event Viewer
with specific messages for success and failure.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 5: Gain hands-on experience with debugging through various tools,


including IDEs, and understand how to set breakpoints, inspect variables,
and trace code execution.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Examining Variable Contents

Key takeaways from this topic...

1. The ability to examine variable contents during code execution can reveal
issues and help debug in real-time.
2. Many IDEs offer features like watch windows or immediate windows that
make it easier to inspect variables without stopping code execution.
3. Some debugging tools allow setting conditional breakpoints based on variable
values, enabling targeted debugging.

Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Understanding and Examining Variable Contents in Programming

In programming, the capacity to critically examine the contents of variables as a


program runs is a highly useful skill for developers, which enables them to gauge the
transformations data undergoes throughout runtime, assisting in spotting and
rectifying bugs and other discrepancies. Mastery of techniques to explore variable
contents can be a vital component in a programmer's arsenal, ensuring seamless
system operations.

Understanding Variables

A primary step in this process is comprehending the characteristics and functions of


variables in a program. Variables, the storage units in a program, harbour data that
may vary during the runtime. Characterised by a unique name and type, they are
central in storing data manipulated within a program.

Techniques to Examine Variable Contents

Programmers have at their disposal several tools and methods to monitor variable
values and behaviours during runtime, including:
● Print Statements
An uncomplicated technique wherein developers infuse print statements in
the code to visualise the variable values at certain stages of execution.
● Debuggers
A feature in many Integrated Development Environments (IDEs),
debuggers enable developers to halt the execution (via breakpoints) and
scrutinizes the existing variable values, even allowing line-by-line code
progression to witness variable value alterations.
● Watch Expressions
A specialised function within debuggers where developers can earmark
certain variables to “watch,” facilitating constant display of these variable
values as the program executes.

Further Reading

GDB - Viewing Data

Links to an external site.

Explore how to inspect variables (program state) in GDB using the print and info
locals commands. Learn how to use GDB commands such as print and info locals as
tools to view the state of a program without the need to insert printf C code
statements and recompile the program.

Liz Willer, 2020, 'GDB - Viewing Data', [online] accessed 31 January 2024,
<https://www.cse.unsw.edu.au/~learn/debugging/modules/gdb_viewing_data/>

Ways to Look at the Values of Variables While Debugging in Visual Studio

Links to an external site.


Consider these seven different ways to inspect the values of your variables while
debugging through your code in the Visual Studio debugger without modifying your
code.

Aaron Hallberg, 2016, '7 Ways to Look at the Values of Variables While Debugging in Visual Studio',
Microsoft Dev Blog [online] accessed 31 January 2024,
<https://devblogs.microsoft.com/devops/7-ways-to-look-at-the-values-of-variables-while-debugging-in-
visual-studio/>

Section 2: Practical Applications and Real-world Implementation

Analysing variable contents finds utility in several real-world applications.

● Bug Identification and Resolution


Through the keen observation of variable value alterations, programmers
can detect logical errors or bugs, pinpointing moments where values differ
from expected results.
● Optimising Code
Vigilant tracking of stored variable values can identify opportunities to
refine the code, improving the program’s performance and speed.
● Data Validation
Using this technique ensures the alignment of processed data with the
program’s intended functionality, confirming the validity of inputs and
outputs.

Section 3: Case Study - Elevating Software Efficiency


Background

At the forefront of finance technology, FinTech Hub was grappling with the task of
sustaining the reliability and performance of its software applications. The intricate
algorithms and expansive datasets in play mandated a precise approach to
debugging to avert system failures and inaccurate data computations.

Problem Statement

The established debugging procedures were gradually becoming burdensome,


inducing delays in rolling out new functionalities and updates. There was a pressing
need for a more systematic strategy to pinpoint and amend issues efficiently, without
hindering the developmental cycle.

Implementation

To revamp the debugging procedure, a pivotal decision was made to amplify the
techniques employed to examine variable contents. The initiative unfolded as
follows:
● Training
A comprehensive training module was introduced to acquaint developers
with advanced debugging tools and techniques, including the proficient
use of watch expressions and breakpoints.
● Integrating Advanced Debuggers
Embedding sophisticated debugging tools into the development landscape
enabled a more nuanced and detailed investigation of variable contents.
● Code Reviews
A routine of regular code reviews was instituted, fostering a culture where
developers scrutinised variable values to pinpoint potential enhancements
and optimisation avenues.

Outcome

The heightened focus on scrutinising variable contents transformed the debugging


landscape at FinTech Hub. Developers could now swiftly isolate and rectify glitches,
slashing debugging time and hastening the development pace. The evolved
techniques culminated in the creation of more reliable and sturdy software solutions,
nurturing an ethos of quality and efficiency within the development squad. This case
elucidates the central role that detailed inspection of variable contents can play in
bolstering software development procedures.

Topic 2. Implementing Logging and Error Handling


Frameworks

Key takeaways from this topic...

1. Logging frameworks offer a systematic way to trace how data moves through
the system, making it easier to locate issues.
2. A robust error handling framework can catch and manage exceptions, thus
preventing crashes and enabling more graceful failure.
3. Proper logging and error handling can also be used to give constructive
feedback to the end-users, helping them understand what went wrong.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: The Foundations of Logging and Error Handling

Developing software transcends the mere construction of functionalities. An essential


responsibility for developers is to forge systems that are both robust and
straightforward to maintain. In this context, the implementation of logging and error
handling frameworks becomes imperative.
These frameworks function as vital tools in monitoring the health of the system,
facilitating issue diagnosis, and guaranteeing smooth and dependable operations.

Importance of Logging and Error Handling

The process of logging embodies the recording of events within a system, thereby
aiding in the identification, troubleshooting, and resolution of potential issues.
Essentially, it acts as a chronicle of system activities, instrumental in detecting
unusual patterns or behaviours.

Contrastingly, error handling is the methodology employed to address exceptions or


errors that surface during a program’s execution. Proper error handling tactics
facilitate the graceful management of unforeseen scenarios, averting system crashes
and thus fostering stability and reliability in the system.

Section 2: Techniques, Tools, and Practical Applications

Techniques and Tools

Logging

● Log Levels: Employ different log levels such as INFO, WARN, and
ERROR to classify the gravity of log entries.
● Log Aggregation: Centralise log data hailing from diverse sources to
enable streamlined analysis and monitoring.
● Log Rotation: Implement strategies to archive outdated logs and
generate new log files, preventing an overflow of log file data.

Error Handling
● Try-Catch Blocks: Utilise try-catch blocks to encapsulate potentially
exception-throwing code and delineate the handling procedures.
● Custom Error Messages: Develop custom error messages that offer
more detailed insights into the error nature.
● Error Logging: Integrate error logging to document exceptions, facilitating
future analysis and prevention of analogous issues.

Practical Applications

The incorporation of logging and error handling frameworks manifests in numerous


practical applications, including:

● System Monitoring
Undertake continuous system surveillance to pinpoint and flag potential
issues before escalation.
● Troubleshooting
Facilitate swift identification and rectification of problems through log and
error message analysis.
● Security
Amplify system security through vigilant monitoring and documentation of
unauthorized access attempts.

Further Reading

Error Logging in C++

Links to an external site.

Explore this comprehensive guide on implementing error logging in C++ to facilitate


effective error tracking and handling, and learn how to create a simple class to log
program errors.
Reference: Rollbar staff, 2022, 'What is Error Logging in C++', Rollbar Guide, accessed 31 January
2024, <https://rollbar.com/guides/cpp/cpp-error-logging/>

Section 3: Case Study - Enhancing Operational Efficacy at HealthNet Solutions

Background

HealthNet Solutions, a notable player in healthcare technology, was grappling with


recurring system downtimes, which were detrimentally impacting the quality of their
service and client satisfaction levels. The leadership acknowledged the urgent
necessity to strengthen the system's resilience and enhance issue traceability.

Problem Statement

The existing infrastructure was devoid of thorough logging and error handling
mechanisms, culminating in extended downtimes and inefficient troubleshooting
procedures. There emerged a critical need to introduce robust frameworks that could
amplify system stability and facilitate efficient maintenance.

Implementation
HealthNet Solutions embarked on an initiative to construct structured logging and
error handling frameworks, employing the following strategies:

● Development of Logging Framework


Crafting a structured logging framework that systematically categorised
and documented system events.
● Integration of Error Handling Modules
Integrating modules that adeptly captured and addressed exceptions,
mitigating system crashes and simplifying troubleshooting.
● Training and Skill Development
Equipping the development team with the necessary skills to effectively
utilise the newly implemented frameworks, thereby enhancing their
capacity to monitor, identify, and resolve issues proficiently.

Outcome

The inception of these frameworks signaled a monumental shift at HealthNet


Solutions. The system metamorphosed into a more stable and manageable entity,
with downtimes significantly curtailed. The development team could now promptly
pinpoint and resolve issues, markedly elevating service quality and customer
satisfaction levels. This scenario underscores the pivotal role that logging and error
handling frameworks assume in augmenting the reliability and efficacy of software
systems.

Topic 3. Creation of Custom Event Logs

Key takeaways from this topic...

1. Custom event logs provide an audit trail for applications, helping in


troubleshooting and system monitoring.
2. The ability to customise event logs allows for a more granular view of events,
separating them into categories like 'success' and 'failure'.
3. Custom event logs can be integrated with system-level logging tools like the
Windows Event Viewer, providing a unified logging interface.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Introduction to Custom Event Logs and Components

In the realm of software development, the adept management and surveillance of


system activities is of prime importance. Achieving this can be notably facilitated
through the establishment of custom event logs.
These bespoke logs are constructed to monitor and document specific events within
a system, furnishing a nuanced and streamlined avenue for tracking system
behaviours and occurrences. This guide aims to elucidate the critical facets of
creating custom event logs, highlighting their significance and depicting their
utilisation through a practical case study.

Understanding Custom Event Logs

To create custom event logs is to formulate specialised logs that record events
germane to a specific functionality or module within the system. Far from generic,
these logs are crafted to offer detailed insights into particular segments of the
application. Their application extends to recording details about custom applications
or services, enabling focused monitoring and troubleshooting.

Key Components

When embarking on the creation of custom event logs, one should ponder over
several vital components:

● Event Identifiers
Singular identifiers that are allocated to each event type, aiding in their
effortless distinction and promoting efficient filtering and searching.
● Event Categories
The strategy of clustering events into varying categories, dictated by their
characteristics or the modules they pertain to, thereby facilitating
systematic and orderly logging.
● Event Metadata
Incorporation of pertinent metadata such as timestamps, event source,
and event particulars to furnish a well-rounded view of each event.
● Event Severity Levels
The delineation of severity levels to classify events based on their
repercussion, assisting in prioritising response strategies.
Section 2: Applications of Custom Event Logs

The creation of custom event logs finds a place in a myriad of domains, inclusive of:

● Security Monitoring
Establishing custom event logs to exclusively monitor events with security
implications, assisting in the premature detection of potential security
violations.
● Performance Monitoring
Developing logs to oversee the performance metrics of specific modules
or functionalities, fostering proactive performance tuning and
enhancement.
● Compliance and Reporting
Leveraging custom event logs in collating data vital for compliance
reporting, thereby rendering the process more streamlined and efficient.

Section 3: Case Study - Enhancing System Operations at GreenTech Innovations

Background

GreenTech Innovations, a pioneer in fostering sustainable technologies, sought to


amplify its capacities in system monitoring and management. As their project
complexities escalated, the demand for a more focused and efficient methodology
for logging system events became pronounced.
Problem Statement

The conventional event logs utilised by the company were becoming increasingly
challenging for the IT contingent to navigate and pinpoint specific events associated
with their custom-developed applications. The requirement for a more streamlined
approach to log management emerged as a pressing concern.

Implementation

To rectify this, GreenTech Innovations launched a project aimed at crafting custom


event logs, implementing the following strategies:

● Identification of Key Event Types


The inaugural step involved pinpointing the central event types warranting
focused monitoring, based on the distinctive traits of their applications.
● Development of Custom Log Structure
A bespoke log structure was formulated, encapsulating relevant metadata
and categorisation attributes to comprehensively capture the identified
events.
● Integration with Monitoring Tools
The newly created custom event logs were amalgamated with existing
monitoring tools, fostering focused monitoring and expedited
troubleshooting procedures.
● Training and Adoption
The IT brigade underwent training to adeptly utilise the new custom event
logs, thereby amplifying their ability to oversee and manage the system
effectively.

Outcome

The inception of custom event logs markedly uplifted the efficiency of the system
monitoring protocol at GreenTech Innovations. The IT personnel were now equipped
to swiftly identify and react to particular events, diminishing the time and effort
necessitated for troubleshooting.

Additionally, it fostered concentrated monitoring of custom applications, culminating


in enhanced reliability and performance. This case study underscores the
importance and advantages of establishing custom event logs in refining system
monitoring and management procedures.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Understand Conditional Breakpoints in C++
Standard function breakpoints probably help in most debugging sessions. But,
sometimes, there's simply too much code to check, too many objects or cases. What
if you want to filter out code that generates a breakpoint? Here's a look at conditional
breakpoints.

Understand Conditional Breakpoints in C++

Links to an external site.

Reference: Bartlomiej Filipek, 2016, 'Understand Conditional Breakpoints in C++', Visual Studio
Magazine, accessed 31 January 2024,
<https://visualstudiomagazine.com/articles/2016/09/01/understand-conditional-breakpoints.aspx>

Reading: Modern C++ Best Practices for Exceptions and Error Handling
This article discusses the preferred approaches and best practices for handling
errors in modern C++ programming. It emphasizes the use of exceptions as the
preferred way to report and handle both logic errors and runtime errors in most
scenarios. The article covers basic guidelines for robust error handling, such as
using exceptions for exceptional code, employing assertions for conditions that
should never occur, and providing exception guarantees for functions.

Modern C++ Best Practices for Exceptions and Error Handling

Links to an external site.


Reference: Microsoft staff, 2022, 'Modern C++ Best Practices for Exceptions and Error Handling',
Microsoft Learn, accessed 31 January 2024,
<https://learn.microsoft.com/en-us/cpp/cpp/errors-and-exception-handling-modern-cpp>

Reading: Custom C++ Exceptions for Beginners


This article provides a beginner-friendly guide to using custom exceptions in C++. It
explains the basics of exception handling, emphasizing the use of try-catch blocks
and the throw keyword. It demonstrates the process of handling different types of
exceptions and highlights the importance of adding preconditions and postconditions
when deciding when to throw exceptions.

Custom C++ Exceptions for Beginners

Links to an external site.

Reference: Peter Forgacs, 2017, 'Custom C++ Exceptions for Beginners', Peter Forgacs @ GitHub,
accessed 31 January 2024,
<https://peterforgacs.github.io/2017/06/25/Custom-C-Exceptions-For-Beginners/>

Reading: Exception Handling in C++


This article provides an in-depth overview of exception handling in the C++
programming language. It explains that exceptions are runtime anomalies or
abnormal conditions and describes the mechanism of handling these exceptions
using keywords like try, catch, and throw. The article covers the types of exceptions,
the syntax of try-catch blocks, and the advantages of exception handling over
traditional error handling.

Exception Handling in C++

Links to an external site.

Reference: Geeks for Geeks, n.d., 'Exception Handling in C++', Geeks for Geeks, accessed 31
January 2024, <https://www.geeksforgeeks.org/exception-handling-c/>

Reading: try, throw, and catch Statements


This article discusses the implementation of exception handling in C++ using try,
throw, and catch statements.

try, throw, and catch Statements

Links to an external site.


Reference: Microsoft staff, 2023, 'try, throw, and catch Statements', Microsoft Learn, accessed 31
January 2024, <https://learn.microsoft.com/en-us/cpp/cpp/try-throw-and-catch-statements-cpp>

Video: Exception Handling in C++


This video teaches you how to handle errors in your program and how to work with
exceptions on a real-life example.

You'll learn about keywords that are used to work with exceptions: try, catch and
throw, and about different types of exception handlers, including the default handler.

Exception Handling in C++

Links to an external site.

(24:46)

Reference: CodeBeauty, 2021, 'Exception Handling in C++', YouTube, accessed 31 January 2024,
<https://youtu.be/kjEhqgmEiWY>

Reading: TraceLogging C/C++ Quick Start


This article provides a step-by-step guide for incorporating TraceLogging into C/C++
user-mode code for Windows applications. It outlines the prerequisites, including
Microsoft Visual Studio 2013 or later and the Windows 10 SDK, and highlights the
importance of using advapi32.lib to avoid linker errors. The article explains the
process of defining and declaring a provider handle in a header file, registering and
unregistering the provider, and logging events using the TraceLoggingWrite macro.

TraceLogging C/C++ Quick Start

Links to an external site.

Reference: Microsoft staff, 2022, 'TraceLogging C/C++ Quick Start', Microsoft Learn, accessed 31
January 2024,
<https://learn.microsoft.com/en-us/windows/win32/tracelogging/tracelogging-native-quick-start>

Reading: Using C++ to Write Logs in Windows Event Viewer


This article discusses the use of C++ for writing logs in the Windows Event Viewer,
specifically focusing on utilizing NTSTATUS values for error identification. It explains
how NTSTATUS values are associated with error messages and how drivers can use
predefined values or define custom ones for logging.

Using C++ to Write Logs in Windows Event Viewer

Links to an external site.


Reference: Christina Holley, 2023, 'Using C++ to Write Logs in Windows Event Viewer', Copy
Programming, accessed 31 January 2024,
<https://copyprogramming.com/howto/log-to-event-viewer-on-windows-with-c>
Module 9. Code Testing, Performance Monitoring &
Optimisation

source: Freepik

In the complex landscape of software development, testing and performance


monitoring are fundamental. Ensuring that the code runs smoothly, efficiently, and as
intended requires strategic planning and continuous optimisation. This module
focuses on designing tests for codes, monitoring performance, and enhancing
software efficiency through careful analysis and targeted improvements.

In this module, you will explore:

● Learn how to design and implement various test cases to validate the
functionality of applications, focusing on real-world examples such as the
"Add Student" application.
● Dive into the techniques and tools used to monitor application
performance, including RAM and CPU usage, and how to capture baseline
analysis for comparisons.
● Discover the methodologies to improve code performance through specific
changes, how to compare before-and-after metrics, and propose further
optimisations.

To enhance your understanding, we have tailored specific learning activities:

● Designing and Implementing Test Cases for the "Add Student" Application
to Ensure Functionality.
● Monitoring Application Performance Including RAM and CPU Usage, and
Capturing Baseline Analysis.
● Implementing Code Changes to Improve Performance, Comparing
Before-and-After Metrics, and Suggesting Further Optimisations.
Assessment notes
Assessment 2 is due this week so make sure you upload all required
documents to Canvas.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 6: Develop skills in designing effective test cases, monitor software


performance metrics, and understand how to make code optimisations
based on performance data.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Performance Monitoring and Analysis


Key takeaways from this topic...

1. Performance monitoring focuses on tracking key system resources like RAM


and CPU to ensure the software runs efficiently.
2. Capturing baseline metrics is critical for making meaningful comparisons and
for understanding how changes will impact performance.
3. Monitoring tools can help identify performance bottlenecks, aiding in targeted
optimisation efforts.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Importance of Designing Tests and Approaches


In the domain of software development, testing stands as a pivotal phase that
vouches for the reliability and robustness of the code. It encompasses the
scrutinising of code functionalities to ensure adherence to outlined requirements and
flawless operation without glitches. This portion delves deeply into the vital
procedures and methodologies entailed in crafting tests for codes, supplemented by
a practical case study to vividly illustrate the concept.

Designing Tests

The crafting of tests for codes is more than just an auxiliary step, embodying a
central element in the software development lifecycle. It facilitates the early detection
of bugs, consequently conserving time and resources as the project progresses.
Moreover, it serves to validate that alterations instated in the code do not negatively
impact pre-existing functionalities, thereby upholding a superior standard of quality
and dependability.

Further Reading

Overview of Test Design Techniques in Software Development

Links to an external site.


Explore the various types of test design techniques, including specification-based
(black-box) techniques and learn to select the right technique based on factors such
as system type, regulatory standards, customer requirements, risk levels, and
tester's skills.

Reference: 2018, 'Overview of Test Design Techniques in Software Development', Test Automation
Resources, accessed 31 January 2024,
<https://testautomationresources.com/software-testing-basics/software-test-design-techniques/>

Approaches to Code Testing

When tasked with code testing, one may opt for a range of approaches,
encompassing:

● Unit Testing
This procedure targets the minutest units of code, typically singular
functions or methods, validating their correct operation in isolation.
● Integration Testing
This form of testing focuses on assessing the interplay between diverse
units of code, verifying their seamless operation upon integration.
● System Testing
At this juncture, the entire system undergoes scrutiny to affirm its
compliance with delineated requirements and overall functional
proficiency.
● Acceptance Testing
This approach entails evaluating the system from the vantage point of the
user, ensuring it satisfies their necessities and anticipations.

Further Reading

Unit and Functional Tests in a Nutshell


Links to an external site.

Explore the difference between unit and functional tests and how to perform them
with the use of a testing framework - the Google Test Framework in particular.

Reference: 2017, 'Unit and Functional Tests in a Nutshell', Coderwall, accessed 31 January 2024,
<https://coderwall.com/p/zj8kjg/unit-and-functional-tests-in-a-nutshell>

Section 2: Practical Steps in Designing Tests

For the crafting of efficacious tests for codes, heed the following steps:

● Requirement Analysis
Commence with a lucid comprehension of the requirements and
functionalities that the code is anticipated to deliver.
● Test Case Design
Forge detailed test cases that enumerate the input conditions, execution
protocols, and anticipated outcomes.
● Test Data Preparation
Fabricate pertinent data requisite for testing, aimed at assessing the
functionality of the code.
● Test Execution
Implement the devised tests, either manually or utilising automated testing
instruments, and record the outcomes.
● Result Analysis
Engage in a detailed analysis of the results to pinpoint discrepancies and
areas where the code potentially falls short of expectations.
● Feedback and Iteration
Grounded on the test outcomes, confer feedback and implement
necessary adjustments to bolster the code’s performance and reliability.

Section 3: Case Study - Enhancing Code Quality at TechNest


Background

TechNest Solutions, a burgeoning software development entity, aspired to amplify


the calibre of its codebase to cater to the escalating demands of their clientele and
maintain a competitive edge in the industry.

Problem Statement

The incumbent testing protocols at the firm lacked sufficient rigour, engendering a
heightened frequency of bugs and errors permeating the production sphere, which
marred the user experience and tarnished the brand’s standing.

Implementation

To rectify this, TechNest Solutions overhauled its testing mechanisms by instituting a


comprehensive code testing strategy, featuring:

● Developing a Testing Protocol


A delineated testing protocol was formulated, encompassing diverse
testing tiers such as unit, integration, and system testing, to warrant a
meticulous appraisal of the code.
● Training and Skill Enhancement
The development cadre underwent training in the paramount practices for
code testing, augmenting their proficiency and capabilities in devising
potent tests.
● Automated Testing
The integration of automated testing tools was initiated to expedite and
streamline test executions, fostering regular and consistent testing
patterns.
● Feedback Loop
A feedback conduit was established, whereby test results were scrutinised
and the gleaned insights utilised to foster continual enhancements to the
code.

Outcome

The refurbished testing strategy precipitated a notable elevation in the quality of the
code generated at TechNest Solutions. Bugs and errors were pinpointed early in the
development trajectory, conserving both time and resources.

The streamlined testing protocols further facilitated quicker releases, aiding the firm
in adhering to project deadlines more adeptly. This endeavour highlighted the
quintessential role of devising tests for codes in augmenting software quality and
dependability.

Topic 2. Performance Monitoring and Analysis

Key takeaways from this topic...

1. Performance monitoring focuses on tracking key system resources like RAM


and CPU to ensure the software runs efficiently.
2. Capturing baseline metrics is critical for making meaningful comparisons and
for understanding how changes will impact performance.
3. Monitoring tools can help identify performance bottlenecks, aiding in targeted
optimisation efforts.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Performance Monitoring

Performance monitoring and analysis stand as vital undertakings in the software


development cycle. This comprises a collection of procedures dedicated to verifying
the accurate and proficient operation of software applications.
This topic aims to give learners an insight into the effective monitoring and analysis
of software system performance, supplemented by a practical case study to help you
understand it in a real world context.

Understanding Performance Monitoring

Central to software development is the commitment to ensure that applications not


only function properly but also perform with the optimum efficiency. Performance
monitoring is tasked with the ongoing evaluation of the operational aspects of the
software, pinpointing sectors that might benefit from enhancements or modifications.
The primary facets assessed during this phase are:

● Response Time: The duration necessitated for a system to reply to a


user's enquiry.
● Resource Utilisation: Observing the consumption of system resources
such as memory, CPU, and network bandwidth.
● Throughput: The quantum of transactions the system processes within a
specified time span.
● Error Rate: The recurrence rate of errors during the system's functioning.

Section 2: Performance Analysis and Steps in Monitoring and Analysis

Implementing Performance Analysis

Following the monitoring stage, performance analysis emerges as the subsequent


step involving the scrutiny of data procured during monitoring, to pinpoint potential
improvement zones. This procedure may encompass:

● Analysing Bottlenecks
Identifying segments in the code or system configuration that might be
inducing delays or inefficiencies.
● Capacity Planning
Anticipating forthcoming system demands and strategising accordingly to
circumvent performance hitches.
● Optimisation
Instituting alterations to boost the system's efficiency based on the results
of the analysis.
● Reporting and Documentation
Crafting detailed reports to record the discoveries and enhancements
applied.

Steps in Performance Monitoring and Analysis

To enact performance monitoring and analysis, adopt the following procedures:

● Setting Benchmarks
Formulate baseline performance indicators to which the system's
performance can be juxtaposed.
● Continuous Monitoring
Employing tools and technologies for ceaseless system performance
monitoring, accruing essential operational data.
● Data Analysis
Examining the amassed data to discern patterns, trends, and potential
areas of concern.
● Implementing Improvements
Implementing necessary alterations to the system to elevate its efficiency,
based on the analytical findings.
● Feedback and Iteration
Upholding a loop of continual refinement by persistently observing and
analysing the system's performance, effectuating adjustments as required.

Section 3: Case Study - Performance Optimisation

Background
Skyward Industries, a well-entrenched e-commerce enterprise, was grappling with
escalating user traffic, which was exerting pressure on their existing system
infrastructure.

Problem Statement

Owing to a surge in user numbers, the system started manifesting stress signs,
including delayed response times and recurring downtimes, adversely impacting the
user experience and potentially diminishing sales.

Implementation

To counteract this, Skyward Industries embarked on a comprehensive performance


monitoring and analysis endeavour. The project encapsulated:

● Implementing Monitoring Tools


The initiative commenced with the integration of sophisticated monitoring
instruments to incessantly evaluate the system's performance.
● Gathering and Analysing Data
The team accumulated data over a duration and analysed it to identify the
prevailing bottlenecks and sectors needing improvement.
● Optimisation Initiatives
In light of the analysis, a series of optimisation moves were instigated,
encompassing server augmentations and code refinements to improve
system performance.
● Routine Performance Reviews
Skyward Industries instituted periodic performance assessments to
continually oversee the system's functionality and implement necessary
adaptations.

Outcome
The venture resulted in a notable amelioration in system performance, denoted by
swifter response times and diminished downtimes. The initiative also promoted more
adept capacity planning, aiding the company in gearing up for further expansion
effectively.

This scenario underlines the critical role of performance monitoring and analysis in
guaranteeing system scalability and delivering a superior user experience.

Topic 3. Performance Improvement and


Optimisation

Key takeaways from this topic...

1. Initially, focus on "low-hanging fruits" for performance gains—small changes


that yield significant improvements.
2. Using metrics to compare performance before and after code changes
quantifies the impact of your optimisation efforts.
3. Performance optimisation is an ongoing process that should adapt as
codebase evolves and new performance data becomes available.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels
Collapse All

Panels

Section 1: Performance Improvement and Optimisation

Performance improvement and optimisation stand as vital closing phases in the


software development cycle. These activities concern the fine-tuning of the system to
ensure peak functioning efficiency, thereby promising users a smooth and satisfying
experience.

This topic will familiarise you with the fundamental concepts and techniques behind
advancing and optimising system performance, supplemented with a relevant case
study to grant a deeper comprehension.

Understanding Performance Improvement

Within software development, performance improvement is a perpetual activity


concentrated on upgrading various aspects of a system to meet or surpass the
established performance standards. This may involve a broad spectrum of activities,
including but not limited to:
● Code Optimisation
Revamping the code to eliminate redundant components and streamline
operations, thus accelerating execution times.
● Database Tuning
Modifying the database settings and configurations to enable quicker data
access and storage.
● Hardware Upgrades
Enhancing the physical infrastructure, such as augmenting memory or
upgrading servers, to accommodate higher performance levels.
● Network Improvements
Upgrading the network setup to decrease latency and enhance data
transfer rates.

Further Reading

C++ Performance Optimization Best Practices

Links to an external site.

Explore various techniques and best practices for optimizing C++ code.

Reference: Ivan Chiklikchi, 2023, 'C++ Performance Optimization Best Practices', Hackernoon,
accessed 31 January 2024, <https://hackernoon.com/c-performance-optimization-best-practices>

Section 2: Implementation of Performance Optimisation

Implementing Performance Optimisation

Performance optimisation is a detailed process encompassing the analysis and


fine-tuning of various system components to secure optimal operation. The
procedure generally incorporates:
● Identifying Performance Goals
Designating clear and quantifiable performance goals that the system
aims to achieve.
● Benchmarking
Instituting benchmarks to juxtapose the present performance standards
against the set objectives.
● Performance Testing
Conducting examinations to pinpoint areas where the system's
performance can be augmented.
● Optimisation Implementation
Enacting optimisation strategies to reach the intended performance levels.
● Monitoring and Adjustment
Persistently overseeing the system's performance and initiating necessary
modifications to preserve optimal functioning.

Further Reading

Performance Testing Tutorial

Links to an external site.

Explore the different types of performance testing in software development and


common performance issues. Learn to assess the speed, response time, stability,
reliability, scalability, and resource usage of a software application under specific
workloads.

Reference: Thomas Hamilton, 2024, 'Performance Testing Tutorial – Types (Example)', GURU99,
accessed 31 January 2024, <https://www.guru99.com/performance-testing.html>

Section 3: Case Study - Enhancing Operations at Horizon E-Solutions

Background
Horizon E-Solutions, a rapidly expanding e-service provider, was endeavoring to
consolidate its market stance by providing users with a peerless service experience.

Problem Statement

Nevertheless, their progress was obstructed by regular system lags and latency
challenges, which negatively influenced user contentment and obstructed their
growth pathway.

Implementation

To mitigate these obstacles, Horizon E-Solutions launched a thorough performance


improvement and optimisation project, which entailed:

● Analysis of Current Performance Levels


The first stage comprised an extensive review of the existing system
performance to pinpoint the prevailing gaps.
● Development of a Strategic Plan
Post-analysis, a strategic roadmap was formulated to address the
recognised performance bottlenecks.
● Optimisation Measures
A range of optimisation strategies were instituted, including code
improvements, database tuning, and network enhancements, to boost
system performance.
● Continuous Monitoring and Adjustments
A mechanism for ongoing supervision and modifications was established
to guarantee consistent optimal performance.

Outcome
The venture manifested in significant advancements, with the system now
demonstrating reduced latency and amplified transaction speeds, heightening user
satisfaction and fostering business expansion. This case demonstrates the
transformative potential of performance improvement and optimisation efforts,
illustrating their capacity to propel a business forward by delivering a superior service
experience to users.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Video: Software Testing Explained
This video provides a brief overview of software testing and its significance in the
dynamic and complex world of software development. It emphasizes the challenges
developers face in understanding every layer of abstraction and the evolving
requirements.

Software Testing Explained

Links to an external site.


Reference: Fireship, 2021, 'Software Testing Explained', YouTube, accessed 31 January 2024,
<https://youtu.be/u6QfIXgjwGQ>

Video: Do you Even Test?


A tutorial video that discusses in detail what testing is and demonstrates how to
integrate one of the most used testing frameworks (Google Test) into a CMake
project.

Do you Even Test?

Links to an external site.

Reference: Code for yourself, 2022, 'Do you Even Test?', YouTube, accessed 31 January 2024,
<https://youtu.be/pxJoVRfpRPE>

Reading: Test Case Design Techniques in Software Testing


Test case design techniques are the key to planning, designing, and implementing
tests for software applications. These techniques involve various steps that aim to
ensure the effectiveness of test cases in uncovering bugs or other defects in
software programs. This blog post will review all these techniques, including their
pros and cons and when to use them.

Test Case Design Techniques in Software Testing

Links to an external site.

Reference: Kiruthika Devaraj, 2023, 'Test Case Design Techniques in Software Testing', Testsigma,
accessed 31 January 2024, <https://testsigma.com/blog/test-case-design-techniques/>

Reading: Introduction to Unit Testing with Google Test


In modern software development, unit testing plays a vital role in ensuring the
reliability, stability, and maintainability of code. By testing individual components of a
program in isolation, developers can catch bugs early, verify expected behaviors,
and refactor code with confidence. Google Test, also known as GTest, is a popular
framework for unit testing C++ code. This article explores the fundamentals of GTest
and how it can improve the quality of your C++ projects.

Introduction to Unit Testing with Google Test

Links to an external site.


Reference: Chittaranjan Sethi, 2023, 'Introduction to Unit Testing with Google Test (GTest)', Medium,
accessed 31 January 2024,
<https://medium.com/@chittaranjansethi/introduction-to-unit-testing-with-google-test-gtest-in-c-344a8
9b8eb4>

Reading: C++ Unit Testing - A Complete Guide


Unit testing is a crucial aspect of modern software development, ensuring the
reliability and correctness of your C++ codebase. This article covers just about
everything you need to know about C++ unit testing, from the basics to advanced
practices, along with real-world examples.

C++ Unit Testing: A Complete Guide with Examples and Best Practices

Links to an external site.

Reference: Rahnuma Tasnim, 2023, 'C++ Unit Testing: A Complete Guide with Examples and Best
Practices', Software Testing Stuff, accessed 31 January 2024,
<https://www.softwaretestingstuff.com/c-unit-testing>

Reading: C++ Testing - Its Importance and Implementation


This comprehensive guide to C++ testing covers numerous aspects of testing,
including unit, integration, and functional tests, highlighting the importance of code
coverage and reliability. It provides insights into setting up the testing environment,
choosing the right testing framework, and writing test cases, covering topics such as
test-driven development, advanced testing techniques, debugging failed tests, and
automating tests. Best practices in C++ testing are highlighted.

C++ Testing: What is its Importance and Implementation

Links to an external site.

Reference: Severin Ilya, 2023, 'C++ Testing: What Is Its Importance And Implementation', Market
Splash, accessed 31 January 2024, <https://marketsplash.com/tutorials/cpp/cplusplus-tester/>

Reading: Write Unit Tests for C/C++ in Visual Studio


This article provides a comprehensive guide on writing unit tests for C and C++ code
in Visual Studio. The article covers the basic test workflow, including using the Test
Explorer window, and highlights that Visual Studio supports various C++ test
frameworks such as Microsoft Unit Testing Framework, Google Test, and Boost.Test.
It explains the steps to create and run unit tests in Visual Studio 2017 and later
versions.

Write Unit Tests for C/C++ in Visual Studio

Links to an external site.

Reference: Microsoft staff, 2023, 'Write Unit Tests for C/C++ in Visual Studio', Microsoft Learn,
accessed 31 January 2024,
<https://learn.microsoft.com/en-us/visualstudio/test/writing-unit-tests-for-c-cpp>

Reading: Tips for Improving Time-Critical Code


Writing fast code requires understanding all aspects of your application and how it
interacts with the system. This article suggests alternatives to some of the more
obvious coding techniques to help you ensure that the time-critical portions of your
code perform satisfactorily.

Links to an external site.

Tips for Improving Time-Critical Code

Links to an external site.

Reference: Microsoft staff, 2023, 'Tips for Improving Time-Critical Code', Microsoft Learn, accessed
31 January 2024, <https://learn.microsoft.com/en-us/cpp/build/tips-for-improving-time-critical-code>
Reading: Visual Studio 2022 Profiling Tools
A profiler can help you make informed decisions quickly by providing a visual
depiction of execution times and CPU usage for your application. This article
provides a quick look at the most common profiling tools.

Visual Studio 2022: First look at profiling tools

Links to an external site.

Reference: Microsoft staff, 2023, 'Visual Studio 2022: First look at profiling tools', Microsoft Learn,
accessed 31 January 2024,
<https://learn.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour>
Module 10. Recording & Compliance
In the dynamic field of software development, recording and compliance form the
backbone of a reliable and accountable process. This module explores the
importance of meticulously recording test results and ensuring compliance with
program specifications.

Within this module, you will delve into:

● Recording and Documenting Test Results: Learn the importance of


accurate and detailed recording of test results, along with the
methodologies and tools to do so effectively.
● Confirming Compliance with Program Specifications: Discover the
processes and protocols that ensure software aligns with specified
requirements and standards, fostering reliability and integrity.

You'll engage with these key learning activities:

● Design meaningful and effective test cases that accurately assess


functionality and performance.
● Hands-on experience with creating and executing unit tests for specific
modules, using popular tools like Visual C++.
● Engage in thoughtful discussions about the critical role that quality
assurance plays in maintaining the standard of software products.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 6: Develop skills in designing effective test cases, monitor software


performance metrics, and understand how to make code optimisations
based on performance data.
​ SLO 7: Understand the importance of and become proficient in creating
comprehensive documentation for code and software, and learn the
principles of quality assurance for software compliance.

Student Expectations
During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Recording and Documenting Test Results

Key takeaways from this topic...

1. Proper documentation of test results enables traceability, helping developers


and stakeholders understand the history of changes and their impact.
2. Recording test results ensures accountability, providing a paper trail that can
be reviewed for quality assurance and audit purposes.
3. Well-documented test results can provide invaluable insights for future
development efforts, indicating where improvements or refactoring are
needed.

Learner Guide
The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Recording and Documenting Test Results

In software development, the act of recording and documenting test results is much
more than just a formality or bureaucratic requirements; it forms a crucial foundation
in crafting reliable and efficient software products.

This practice facilitates the meticulous collection and analysis of test data, fostering
an abundance of information that can be referenced in the future to ensure
compliance and a quality end product. In this section, we will explore each aspect,
complemented with a case study that demonstrates its practical implementation.

Why Record and Document Test Results?


Recording and documenting test results go beyond mere formalities; they are
fundamental steps in assuring quality. The reasons are manifold:

● Facilitates Troubleshooting
○ Error Tracing
Aids in backtracking errors to their origin, paving the way for
targeted corrections.
○ Pattern Identification
Aids in discerning patterns, forecasting potential issues before
they escalate to critical levels.
● Promotes Transparency and Collaboration
○ Team Alignment
Keeps all team members in sync and abreast of the current
project status.
○ Client Communication
Assists in updating the client about the progress and quality of
the development procedure.

Components Involved

1. Test Case Documentation


○ Detailing various testing scenarios meticulously, noting the
expected and actual results along with the utilised test data.
2. Error Logging
○ Immediate Reporting: Prompt recording of any issues detected
during testing to prevent data loss.
○ Detailed Description: Maintaining comprehensive error logs to
assist the development team in rectification efforts.
3. Compliance Confirmation
○ Specification Adherence: Guaranteeing the software aligns with
the stipulated specifications outlined at the project's inception.
○ Regulatory Compliance: Ensuring adherence to pertinent industry
standards and regulations.

Section 2: Case Study - Refining Operations at a Healthcare Facility


Background

A healthcare establishment opted to upgrade its existing patient management


system to a more sophisticated, automated solution. A designated development
team was tasked with crafting a customised system, tailored to satisfy the facility's
distinctive needs. This new system aimed to streamline operations, diminish manual
errors, and elevate patient care through functionalities like appointment scheduling,
electronic medical records, and billing processes.

The Challenge

The incumbent system was marred by various setbacks including data


inconsistencies and recurrent downtimes, negatively influencing the healthcare
facility's daily functions. The challenge entailed developing not just a feature-rich
system but also a robust and reliable one, warranting an exhaustive and
well-documented testing regime.

Approach

The development team commenced the project with a clearly delineated testing
strategy, which underscored the importance of a detailed recording and
documentation of test results. The structure of the testing process was as follows:

● Requirement Gathering and Test Planning


The team diligently assembled all the prerequisites and devised detailed
test plans, encapsulating a comprehensive array of test cases that
explored all plausible scenarios.
● Implementation and Recording
As development unfolded, regular tests were conducted, with results being
recorded scrupulously. This included noting the inputs used, expected
outcomes, and the actual results encountered.
● Error Logging and Resolution
Any identified issue was logged in depth, encompassing the conditions
under which it surfaced and any error messages exhibited. This error log
facilitated swift issue identification and resolution by the development
team.

Outcome

The detailed recording and documentation of test results empowered the team to
swiftly pinpoint and tackle issues, considerably trimming down time spent on
troubleshooting and corrections. Moreover, the recorded data and documented
outcomes served as a tangible progress tracker, fostering transparent
communications with stakeholders, including the healthcare facility's administration.

Furthermore, the well-documented testing procedure ensured a seamless transition


to the new system, encountering minimal issues. The healthcare facility witnessed a
notable uplift in operational efficiency and the quality of patient care, courtesy of the
new, more dependable system.

Conclusion

This case study illustrates the profound influence that detailed recording and
documentation of test results can wield on the success of a software development
venture. The meticulous strategy adopted by the development team not only
smoothed the development trajectory but also culminated in a product that met the
lofty expectations set initially. Through systematic recording and documentation, the
team managed to craft a solution that significantly uplifted the healthcare facility's
operations, showcasing the pivotal role this practice holds in software development.

Topic 2. Confirming Compliance with Program


Specifications

Key takeaways from this topic...


1. Compliance checks ensure that the software aligns with its initial objectives
and meets specified requirements.
2. Confirming compliance is also crucial for meeting legal and regulatory
standards, especially in sectors like healthcare, finance, and government.
3. Ensuring compliance with program specifications often leads to higher
customer satisfaction, as the end product is more likely to meet user
expectations.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Confirming Compliance with Program Specifications


Ensuring that a software application meets the outlined program specifications is a
critical step in the development process. This involves meticulously checking that
each feature and function operates as per the defined criteria, ensuring the reliability
and effectiveness of the final product. In this section, we will explore various
strategies and techniques that can be employed to confirm compliance with program
specifications.

● Specification Documents
Before starting with the compliance checks, it is crucial to have
well-detailed specification documents that clearly outline the expected
functionality and behaviour of the application.
● Compliance Checklist
Developing a compliance checklist, derived from the specification
documents, to serve as a reference point for all compliance verification
activities.
● Automated Testing
Implementing automated testing where possible, to efficiently verify that
the application meets the specified criteria, covering aspects such as
functionality, performance, and security.
● Manual Reviews
Conducting manual reviews to ensure that the more nuanced aspects of
the specifications, which might not be captured through automated testing,
are thoroughly checked.
● Peer Reviews
Engaging in peer reviews to bring different perspectives and expertise into
the compliance verification process, helping to identify potential issues or
oversights.

Practical Application

To put these concepts into practice, here is a step-by-step guide that you can follow:

1. Review Specification Documents


Begin by thoroughly reviewing the specification documents to understand the
expected behaviour of the application.
2. Develop Compliance Checklist
Based on the specifications, develop a comprehensive compliance checklist
that outlines all the criteria that the application needs to meet.
3. Conduct Testing
Employ both automated and manual testing techniques to verify compliance
with the listed criteria.
4. Document Results
Record the results of the testing process meticulously, noting any deviations
from the expected outcomes.
5. Peer Review and Feedback
Arrange for peer reviews to garner feedback and identify areas that might
require further investigation or adjustment.
6. Implement Changes
Work on addressing the identified issues and making necessary adjustments
to ensure full compliance with the specifications.
7. Final Review
Conduct a final review to confirm that all issues have been addressed and
that the application fully complies with the program specifications.

Further Reading

Standards and Compliance in Software Development: A Comprehensive Guide

Links to an external site.

Explore standards and compliance as guidelines and frameworks ensuring


consistent and high-quality software development.

Reference: Charanjeet Singh, 2023, 'Standards and Compliance in Software Development: A


Comprehensive Guide', Search My Expert, accessed 31 January 2024,
<https://www.searchmyexpert.com/resources/software-development/standards-and-compliance>

Section 2: Case Study - Implementing a Secure Online Banking System

Background
In response to the evolving digital landscape, a leading financial institution embarked
on a pivotal project to upgrade its online banking system. The objective was to
facilitate a more secure and user-friendly experience for its customers. This
significant undertaking was grounded on stringent specifications, which were
meticulously crafted to address essential facets such as improved security protocols,
enhanced performance, and a refined user experience.

Approach

● Setting Clear Specifications


A dedicated team worked assiduously to develop clear and detailed
specifications for the project. This foundational step involved the
integration of advanced features like robust data encryption protocols to
safeguard sensitive customer information, the incorporation of multi-factor
authentication for heightened security, and the design of an intuitive user
interface to foster a pleasant and efficient user experience.
● Developing a Compliance Checklist
The next critical phase was the formulation of a comprehensive
compliance checklist, aligned with the detailed specification documents.
This checklist served as a blueprint, delineating the critical criteria and
benchmarks that the new system was expected to meet, thereby guiding
the development team in their pursuit of crafting a system that would meet
the institution’s high standards.
● Testing and Verification
During the development phase, a multifaceted approach to testing and
verification was adopted. This involved a judicious blend of automated and
manual testing techniques, tailored to meticulously verify the system’s
compliance with the set specifications. Special emphasis was placed on
security features, with a series of simulation and penetration tests
conducted to identify potential vulnerabilities and fortify the system against
them.
● Feedback and Adjustments
Peer reviews were an integral component of the development process.
Conducted at various stages, these reviews facilitated the gathering of
insightful feedback, fostering a culture of continuous improvement. The
feedback was instrumental in making necessary adjustments, thereby
fine-tuning the system to align seamlessly with the outlined specifications.
Outcome

The culmination of the project marked the successful launch of a modernised online
banking system, epitomising security and user-friendliness. The adherence to the
compliance checklist played a pivotal role in the project’s success, ensuring the
delivery of a system that not only met but surpassed the stipulated specifications.

The meticulous approach adopted during the development process underscored the
institution’s commitment to delivering a product that stood as a beacon of reliability
and security in the online banking sector.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Test, Execution and Recording
This article discusses the importance of testing, execution, and recording in the
quality assurance cycle for products or processes. It emphasizes the need for
appropriate testing based on the significance of the design element, highlighting that
tests should align with regulatory compliance and ongoing quality standards. The
scope of testing should cover both expected criteria and potential deviations from the
norm.

Test, Execution and Recording

Links to an external site.

Reference: 3SL staff, 2021, 'Test, Execution and Recording', 3SL blog, accessed 31 January 2024,
<https://www.threesl.com/blog/test-execution-and-recording/>

Reading: Verification vs. Validation in Software


This article explores the essential concepts of verification and validation in software
testing. Software testing, a crucial process in ensuring functionality and behaviour
alignment, involves these two key elements. Verification focuses on determining
whether the software adheres to specified design and development requirements,
while validation checks if the end product truly satisfies the client's needs. To
facilitate a deeper understanding, a valuable eBook on IT Requirements Gathering is
available for free download.

Verification vs. Validation in Software: Overview & Key Differences

Links to an external site.

Reference: Leary C., 2021, 'Verification vs Validation in Software: Overview & Key Differences', BP
Logic blog, accessed 18 January 2024,
<https://www.bplogix.com/blog/verification-vs-validation-in-software>

Reading: Test Management and Reporting


This article explores the key concepts, process, and tools involved in test
management and reporting.

Test Management and Reporting

Links to an external site.

Reference: Foram Bhatt, 2023, 'Test Management and Reporting', Medium (website), accessed 18
January 2024,
<https://medium.com/@foramdbhatt13/test-management-and-reporting-b22bb90b00ba>

Reading: How to Write a Good Test Summary Report


A test report summary contains all the details of the testing process—what was
tested, when was it tested, how it was tested, and the environments where it was
tested. Compared to those created in the Waterfall versions, the test summary report
in Agile development processes is less formal and more focused on the results.

This article discusses what a test summary report is and how it can help in software
development lifecycle processes.

How to Write a Good Test Summary Report

Links to an external site.

Reference: The Nerdy Geek, Community Contributor, 2023, 'How to Write a Good Test Summary
Report', Browser Stack (website), accessed 31 January 2024,
<https://www.browserstack.com/guide/how-to-write-test-summary-report>

Reading: The Importance of Compliance and Security in Software Development


This article emphasizes the critical importance of compliance and security in
software development, particularly in light of the rising trends in cyber threats and
data breaches. It highlights the necessity of incorporating security measures at every
stage of the software development process to mitigate the risks of malicious attacks
and data breaches. The piece discusses various compliance standards, such as
GDPR, ISO 27001, ISO 22301, PCI DSS, HIPAA, SOX, and NIST, explaining their
requirements and implications for software developers.

The Importance of Compliance and Security in Software Development

Links to an external site.

Reference: Jakub Ciupka, 2024, 'The Importance of Compliance and Security in Software
Development', selleo blog, accessed 31 January 2024,
<https://selleo.com/blog/the-importance-of-compliance-and-security-in-software-development>

Reading: 4 Software Compliance Gotchas to Avoid


This resource is a comprehensive guide to software compliance in regard to security
and data privacy. It argues that companies should move beyond mere “checkbox”
software compliance, and create and maintain customer data privacy documentation
per government requirements, conform to complex modern software compliance
standards in regulated markets, and integrate application security into the
development process.

4 Software Compliance Gotchas to Avoid

Links to an external site.

(PDF)

Reference: Synopsys, 2020, '4 Software Compliance Gotchas to Avoid', Synopsys, accessed 31
January 2024,
<https://www.synopsys.com/content/dam/synopsys/sig-assets/ebooks/eb-software-compliance-gotcha
s.pdf>
Module 11. Documentation and Code Maintenance
This module provides a comprehensive exploration of the integral aspects of code
documentation and maintenance. Aimed at ensuring long-term efficiency and
readability, the module addresses key topics such as organisational guidelines,
coding standards, and the application of internal documentation to code.

By the end of this module, you'll be well-versed in creating maintainable code and
understanding its documentation.

Within this module, you will learn about:

● Organisational Guidelines and Coding Standards: Focus on the


guidelines and standards that organisations typically enforce to maintain
code quality. You'll learn how these rules create a cohesive coding
environment and facilitate easier maintenance and collaboration among
team members.
● Applying Internal Documentation to Code: Explore the art and science
of embedding documentation directly within the code. This internal
documentation aims to explain complex code logic, note issues or bugs,
and provide clarifications, making the codebase much easier to
understand and maintain.
● Developing and Documenting Maintainable Code: Focuses on the
practices for writing code that not only functions optimally but is also easily
maintainable. You'll learn various techniques for writing clean,
well-documented code that stands the test of time.

You'll engage in these key learning activities:

● See why documentation is a cornerstone in software development.


Through case studies and examples, you'll see how proper documentation
can be the difference between a project’s success and failure.
● Get hands-on with documenting a specific piece of code in this activity.
You'll apply the principles you've learned to produce clear, concise, and
comprehensive documentation, making the code easier to understand and
maintain.
● Have the opportunity to exchange your documentation with peers for
review. This peer review process will help you gain different perspectives
on your work and learn ways to improve its clarity and completeness.

Subject Learning Outcomes


The material in this module relates to the following subject learning outcomes:

​ SLO 7: Understand the importance of and become proficient in creating


comprehensive documentation for code and software, and learn the
principles of quality assurance for software compliance.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), and responding to facilitator
feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Organisational Guidelines and Coding


Standards

Key takeaways from this topic...


1. Adhering to organisational guidelines and coding standards ensures
consistency across the codebase, making it easier to read and maintain.
2. Standards and guidelines facilitate quicker onboarding of new developers, as
they provide a set structure and style to follow.
3. A standardised approach to coding can enhance the overall quality of the
software and ease the process of debugging and updating.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Introduction to Organisational Guidelines and Coding Standards

In the profession of software development, adhering to organisational guidelines and


coding standards is not merely a formality but a pathway to fostering seamless
collaboration and enhancing code maintainability. These guidelines are fundamental
in ensuring a uniform approach to coding which aids in streamlined project progress
and successful outcomes. Let’s delve into the intricate realms of these guidelines
and standards to understand their pivotal role in the software development lifecycle.

Importance of Organisational Guidelines


Organisational guidelines serve as a blueprint for streamlining processes and
cultivating a culture of excellence within a development team. These guidelines help
in formulating realistic and beneficial rules that guide the team’s efforts towards
achieving project goals with proficiency and coherence.

Understanding Coding Standards

Coding standards are the backbone of proficient software development. Abiding by


these standards not only facilitates readability but also simplifies the maintenance
process. These standards primarily encompass various aspects such as adopting
suitable naming conventions, structuring code logically, and incorporating relevant
comments and documentation to aid future references and modifications.

Further Reading

Coding Standards and Guidelines

Links to an external site.

Explore the benefits of adhering to coding standards, such as promoting sound


programming practices, facilitating code reuse, and improving efficiency. Specific
coding standards mentioned include limited use of globals, standard headers for
modules, naming conventions for variables and functions, proper indentation, and
error return values.

Reference: Geeks for Geeks, n.d., 'Coding Standards and Guidelines', Geeks for Geeks, accessed 31
January 2024, <https://www.geeksforgeeks.org/coding-standards-and-guidelines/>

Section 2: Practical Application of Guidelines and Standards


To translate the theory into practice, it’s imperative to engage in real-world
applications. Here, we will explore how to practically apply the discussed concepts in
a work environment:

● Drafting Guidelines
As a starting point, consider drafting a set of guidelines that align with the
organisational goals and foster a harmonious working environment.
● Implementing Coding Standards
Once familiar with the coding standards, focus on implementing these
diligently in your projects to witness the transformation it can bring in terms
of readability and maintainability.

Section 3: Case Study - Implementing Organisational Guidelines and Coding


Standards

Scenario

You are a team member in this dynamic environment. The leadership decides that
it's time to bring a change to uplift the code quality and team collaboration. The
objective is clear: To create a well-structured, maintainable, and uniformly styled
codebase that would streamline the workflow and enhance productivity.

Steps Taken

● Setting Up a Committee
A committee comprising senior developers and project managers was set
up to draft the organisational guidelines and coding standards. They were
tasked with researching and proposing a set of rules that would be both
modern and easy to adopt.
● Drafting the Guidelines
The committee worked diligently to draft comprehensive guidelines that
encompassed best practices in coding, including naming conventions, file
organisation, and commenting. These guidelines were built keeping in
mind the existing challenges and potential growth of the firm.
● Training Sessions
Once the guidelines were drafted, a series of training sessions were
organised. These sessions were interactive, providing team members with
the opportunity to understand the new standards and how to implement
them in their daily workflow.
● Implementation
After the training sessions, the team began to implement the new
standards. A grace period was provided to allow team members to adapt
to the new norms. Peer reviews were encouraged to foster a collaborative
learning environment.
● Feedback and Adjustments
Over time, feedback was collected from the team members about the new
guidelines. Necessary adjustments were made to ensure that the
standards were both efficient and user-friendly.

Outcome

1. Enhanced Code Quality


With the adoption of the new standards, the codebase transformed into a
more structured and readable form. This facilitated easier maintenance and
modifications.
2. Improved Collaboration
The uniform coding style fostered better collaboration among team members.
Code reviews became more productive, with team members being able to
understand and critique each other’s code more effectively.
3. Boosted Morale and Productivity
The clear guidelines and standards uplifted the team’s morale. They now had
a clear roadmap to follow, which eliminated confusion and boosted
productivity.

Conclusion

This case study illuminates the transformative power of implementing organisational


guidelines and coding standards within a software development team. Not only did it
streamline the workflow, but it also fostered a culture of collaboration and excellence,
setting a foundation for the firm's future success.

Learning Activity - Importance of Documentation in


Software Development

Activity Type: Theoretical Study and Group Discussion


Time on Task: Approx. 60 mins

Instructions:

1. Study provided materials or search for articles, papers, and case studies
emphasising the importance of documentation in software development.
2. Prepare a list of key takeaways and reasons why documentation is crucial.
3. In a group setting, discuss your findings and relate them to your own
experiences or projects you're familiar with.
4. Write a summary of the discussion, highlighting the main points and
conclusions reached.

Topic 2. Applying Internal Documentation to Code

Key takeaways from this topic...

1. Good internal documentation makes the code self-descriptive, reducing the


cognitive load on developers trying to understand it.
2. Well-documented code stands the test of time, making it easier to maintain
and update in the future.
3. Effective internal documentation can help in reducing errors, as it provides
contextual information that aids in understanding the code’s functionality and
limitations.
Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Importance of Internal Documentation

In software development, internal documentation serves as a road map that guides


developers through the intricacies of the codebase. It facilitates better understanding
and smoother transitions throughout the lifecycle of a project. This topic will walk you
through the essential aspects of applying internal documentation to your code,
offering both theoretical knowledge and practical strategies to enhance your
documentation skills.

Understanding the significance of internal documentation is the first step in adopting


good coding practices. Effective documentation aids in:

● Simplifying Code Navigation


Developers can quickly locate and understand specific segments of the
code.
● Facilitating Collaboration
A well-documented codebase makes it easier for teams to work together.
● Streamlining Debugging
With clear documentation, identifying and resolving issues becomes more
efficient.
● Ensuring Continuity
Detailed documentation ensures that the project can be easily managed
and extended in the future, even if the original developers are no longer
involved.

Section 2: Strategies for Effective Documentation

Here, we delve deeper into the methodologies and strategies to craft insightful and
useful documentation.

● Comments
Incorporate various forms of comments within your code to convey the
function and purpose of different code sections.
● Descriptive Naming
Choose appropriate and descriptive names for variables, functions, and
classes.
● Maintaining a README File
Maintain a comprehensive README file that encompasses a project
overview, setup instructions, and guidelines.
● API Documentation
Document the API usage thoroughly, offering endpoint descriptions and
examples.
● Change Logs and Version Control
Employ version control systems like Git to track alterations and manage
different versions of the project.
● Including Code Examples
Provide insights through code examples in the form of tutorials or code
snippets.
● Error Handling and Reporting
Develop a robust system for error handling and reporting, incorporating
descriptive error messages and maintaining error logs.

Section 3: Case Study - Enhancing Project Readability through Improved Internal


Documentation

Background
In the heart of a rapidly expanding tech start-up, a group of ambitious developers
embarked on a mission to create a pioneering web application aimed at
revolutionising e-commerce operations. The initial phases of the project were
marked by enthusiasm and rapid development. However, as the team expanded and
the project became more complex, it became apparent that the codebase lacked
sufficient documentation. This gap in internal documentation began causing delays
and confusion, particularly for new members who found it challenging to navigate
and comprehend the project's intricacies.

Scenario

You, having a substantial experience and understanding of the project, are appointed
to lead an initiative to bolster the internal documentation. This task is not only vital to
streamline the ongoing development process but also seen as a strategic move to
set the stage for the project's future scalability and sustainability. The primary
objective is to transform the codebase into a well-documented repository that can
facilitate smoother collaboration and expedite the project’s progression.

Action Plan

To navigate this challenge, you proposed a comprehensive action plan that involved
several strategic steps:

1. Analytical Review of the Current Codebase


Conduct a meticulous review of the existing codebase to pinpoint areas where
documentation was sparse or unclear. This would involve collaborative
feedback sessions with various team members to gather insights into the
current challenges.
2. Developing a Documentation Blueprint
Create a blueprint that outlines the essential documentation elements
required at different levels of the code. This would serve as a guide for the
team to follow during the documentation enhancement process.
3. Revamping Naming Conventions
Initiate a revision of the existing naming conventions, encouraging the use of
descriptive names that delineate the purpose and functionality of different
code elements clearly, thereby avoiding ambiguity.
4. Creating a Comprehensive README File
Craft a detailed README file that encapsulates critical project information,
setup instructions, and contribution guidelines, serving as a central resource
for team members and future contributors.
5. Enhancing API Documentation
Dedicate efforts to enrich the API documentation with clear endpoint
descriptions and practical examples, fostering a user-friendly approach to
interacting with the API.
6. Implementing Error Handling Strategies
Develop robust error handling and reporting strategies, incorporating
descriptive error messages and systematic error logs that streamline the
debugging process.
7. Incorporating Practical Code Examples
Integrate detailed code examples into the documentation to illustrate the
practical usage of various functions and classes within the project, fostering a
deeper understanding and hands-on familiarity with the code.
8. Training and Knowledge Sharing Sessions
Organise regular training sessions where team members can learn about the
new documentation standards and share insights and suggestions to enhance
the documentation further.

Outcome

The concerted effort to improve internal documentation bore significant results:

1. Streamlined Collaboration
Team members found it easier to collaborate, with clear documentation
reducing misunderstandings and facilitating more productive discussions.
2. Accelerated Debugging Processes
The introduction of systematic error handling and reporting strategies made it
easier to identify and resolve issues swiftly, reducing the time spent on
debugging.
3. Enhanced Onboarding Experience
New members could onboard more seamlessly, with the enhanced
documentation providing a clear roadmap to navigate the project's
complexities.
Topic 3. Developing and Documenting Maintainable
Code

Key takeaways from this topic...

1. Code that is both maintainable and well-documented is more scalable,


allowing for easier feature additions and modifications.
2. Prioritising documentation and maintainability can significantly reduce
technical debt over time.
3. Maintainable, well-documented code aids in efficient knowledge transfer
among developers, making team collaborations smoother.

Learner Guide

The Learner Guide provides the core knowledge for this topic. Work through the
materials and be prepared to discuss these in your forums, tutorials or classes.

Expand All

Panels

Collapse All

Panels

Section 1: Strategies for Developing Maintainable Code

In the swiftly evolving sphere of software development, crafting maintainable code is


a cornerstone of successful and sustainable projects. Such an approach not only
eases transitions between various development phases but also ensures effortless
management and adaptation of code in the future. In this segment, we shall delve
deep into strategies pivotal in developing and documenting maintainable code, and
illustrate these principles through a real-world case study.

Strategies for Developing Maintainable Code

● Code Consistency
○ Coding Conventions
○ Code Linting
● Modular Design
○ Decomposition
○ Encapsulation
● Code Comments and Documentation
○ Inline Comments
○ API Documentation
● Version Control
○ Branching Strategy
○ Change Tracking
● Code Reviews
○ Peer Reviews
○ Automated Code Analysis

Section 2: Enhancing Maintainability in a Financial Software System

Background

In a thriving financial firm, the software team was grappling with growing challenges
emanating from an outdated software system. As the firm expanded and
incorporated new members, the inconsistencies in coding standards and sparse
documentation became evident. This scenario not only hampered the onboarding
process but also decelerated the enhancements needed to meet the business's
evolving needs. Identifying this bottleneck, the leadership decided to strategically
revamp the system to bolster maintainability and scalability.
Initial Challenges

● Inconsistent Coding Styles


Various sections of the code were developed by different individuals over
the years, leading to a disparity in coding styles and standards.
● Outdated Documentation
The existing documentation was obsolete, not encompassing the system's
current functionalities, thus posing a significant barrier for newcomers to
comprehend and work on the system.
● Monolithic Architecture
The system adhered to a monolithic architecture, which complicated the
integration of new features or modifications without affecting other
components of the system.

Strategies Implemented

● Coding Standards
The journey commenced with the formulation of comprehensive coding
standards. These norms were meticulously documented and disseminated
throughout the organisation, encouraging a uniform approach to code
development.
● Documentation Overhaul
A dedicated task force undertook the mission to revamp the existing
documentation. This team collaborated closely with veteran members to
develop detailed and contemporary documentation, elucidating the various
system modules clearly and providing guidelines and best practices for
interacting with them.
● Modular Approach
A structural shift to a modular design ensued. Each module was
engineered to handle specific functionalities, fostering easier management
and facilitating potential extensions in the future.
● Version Control and Code Reviews
A robust version control system was instituted to efficiently manage
diverse versions of the code. Regular code reviews became a norm,
aiding in maintaining code quality and fostering knowledge transfer among
team members.
Outcome

The strategic implementations metamorphosed the software system into a more


manageable, maintainable, and scalable entity. New team members could be
onboarded more swiftly, guided by clear documentation and coding standards.
Moreover, the modular structure allowed for faster and more secure feature
deployments, augmenting the system's adaptability and efficiency.

Further Resources
The resources in this section are for further exploration, providing additional
information for deeper insights.

Expand All
Panels
Collapse All
Panels
Reading: Coding Standards and Best Practices to Follow
Coding standards are a set of guidelines and best practices that are used to create
consistent, high-quality code. Consider coding standards as rules, techniques, and
best practices to develop cleaner, more readable, and more efficient code with
minimal errors. They offer a uniform format for software engineers to build
sophisticated and highly functional code.

This article covers the advantages/purpose of maintaining coding standards in


software engineering and discusses 8 coding practices for writing and running clean,
correct code that delivers accurate and relevant results.

Coding Standards and Best Practices to Follow

Links to an external site.

Reference: Shreya Bose (Community Contributor), 2023, 'Coding Standards and Best Practices to
Follow', Browser Stack, accessed 31 January 2024,
<https://www.browserstack.com/guide/coding-standards-best-practices>

Reading: Coding Standards for Quality and Compliance


This article discusses the importance of coding standards in preventing coding
defects, ensuring compliance with industry standards, maintaining consistent code
quality, enhancing software security, and reducing development costs.
Coding Standards for Quality and Compliance

Links to an external site.

Reference: Perforce, n.d., 'Coding Standards For Quality and Compliance', Perforce, accessed 31
January 2024, <https://www.perforce.com/resources/qac/coding-standards>

Video: How to Document Your Code Like a Pro


This video explores the essential principles for creating clear, concise, and effective
code documentation. From commenting to docstrings, you’ll learn how to make your
code documentation shine and improve accessibility for others.

How to Document Your Code Like a Pro

Links to an external site.

(19:03)

Reference: ArjanCodes, 2023, 'How to Document Your Code Like a Pro', YouTube, accessed 31
January 2024, <https://youtu.be/L7Ry-Fiij-M>

Reading: Google C++ Style Guide Overview


A code style guide is a guide to what your source code should look like. It defines the
appearance of the source code. It's important that you format your source code
according to the style guide suggested by the project.

The Google C++ coding style has become very popular and some highlights are
featured in this article.

Google C++ Style Guide Overview

Links to an external site.

Reference: Eric Gregori, 2021, 'Google C++ Style Guide Overview', LinkedIn, accessed 31 January
2024, <https://www.linkedin.com/pulse/google-c-style-guide-summary-eric-gregori/>

Reading: Google C++ Style Guide


C++ is one of the main development languages used by many of Google's
open-source projects. As every C++ programmer knows, the language has many
powerful features, but this power brings with it complexity, which in turn can make
code more bug-prone and harder to read and maintain.

The goal of this guide is to manage this complexity by describing in detail the dos
and don'ts of writing C++ code. These rules exist to keep the code base manageable
while still allowing coders to use C++ language features productively.
Google C++ Style Guide

Links to an external site.

Reference: Google, n.d., 'Google C++ Style Guide', GitHub, accessed 31 January 2024,
<https://google.github.io/styleguide/cppguide.html>
Module 1. Revision & Finalisation
Congratulations on reaching the final module of this comprehensive course on
software development. Having traversed a wide range of topics—from the
fundamentals of programming to intricate data structures, from debugging
techniques to compliance and documentation—this module serves to solidify and
integrate what you've learned so far.

Within this module, you will engage in:

Course Recap: A thorough review of all the key concepts, methodologies, and tools
covered throughout the course to reinforce your learning and address any gaps.

Final Project Submission: Guidelines and best practices for finalising your course
project, which should demonstrate the skills and knowledge you've gained.

Assessment notes

Assessment 3 is due this week so make sure you upload all required
documents to Canvas.

Subject Learning Outcomes

The material in this module relates to the following subject learning outcomes:

​ SLO 1: Acquire a thorough understanding of the various stages and


decision points in the SDLC, including capturing user requirements and
specifications.
​ SLO 2: Gain the ability to create and modify basic data structures such as
arrays and linked lists, along with performing operations like insertion,
deletion, and traversal.
​ SLO 3: Learn to implement complex data structures like stacks, queues,
trees, and graphs, as well as algorithms for sorting and searching.
​ SLO 4: Develop competency in file handling techniques, specifically for
binary files and databases, and understand how to structure source code
across multiple files for better maintainability.
​ SLO 5: Gain hands-on experience with debugging through various tools,
including IDEs, and understand how to set breakpoints, inspect variables,
and trace code execution.
​ SLO 6: Develop skills in designing effective test cases, monitor software
performance metrics, and understand how to make code optimisations
based on performance data.
​ SLO 7: Understand the importance of and become proficient in creating
comprehensive documentation for code and software, and learn the
principles of quality assurance for software compliance.

Student Expectations

During this module, you are expected to spend time working through the prescribed
material prior to attending class. This will enable a more valuable discussion to take
place in online tutorials or conferences, where you will be able to discuss concepts,
present ideas and explore information collaboratively in greater depth.

Accordingly, it is suggested that you allow:

4 hours for facilitated study. This includes guided facilitated study, watching or
attending course lectures (live or pre-recorded), responding to facilitator feedback.

8 hours for personal study. This includes reading through course material,
undertaking learning activities and exploring additional related resources.

Topic 1. Revision and Finalisation

Learning Activity - Finalising Assessment 3


Activity Type: Peer Review, Individual and Group Collaboration
Time on Task: Approx. 45 mins

Instructions:

1. Prepare Drafts: Complete your draft for Assessment 3.


2. Pair Up: Find a peer who is also working on finalising Assessment 3.
3. Exchange Drafts: Share your Assessment 3 drafts with each other.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy