What is Code Review
What is Code Review
Code review is a systematic and collaborative process in software development where one or more developers
examine and evaluate another developer’s code to identify any issues, provide any feedback, and ensure that the
code meets quality standards. The primary goal is to improve the maintainability, quality, and reliability of the
codebase resulting in the overall success of a project while also promoting knowledge sharing and learning
Bug Detection and Prevention: Code review helps detect and address errors, bugs, and issues in the
code before they propagate to production. This early detection significantly helps in reducing the cost
and effort required to fix problems later in the development process or after deployment.
Improved Quality of Code: Code review encourages writing of clean, maintainable, and efficient code.
Reviewers can suggest enhancements, recommend best practices, and ensure that the code aligns with
Consistency: Code review enforces consistency in coding style and practices across the team which
Knowledge Sharing and Learning: Code reviews offer opportunities for knowledge sharing among
team members to learn from one another. Discussions during these reviews can help spread domain
Code Ownership: Code reviewers take partial ownership of the code they review thereby encouraging
trade-offs, and alternative solutions which can lead to improved design decisions and more robust
solutions.
Documentation: Code reviews can also serve as a form of documentation. Review comments and
discussions capture insights and decisions that may not be noticeable from the code itself.
Quality Assurance: Code review is a critical part of quality assurance processes. By thoroughly
analyzing the code changes, teams can ensure that the software meets the functional requirements and
user expectations.
Continuous Improvement: Teams can often use code review as a tool for continuous improvement. By
analyzing the patterns of the feedback of code review, teams can identify recurring issues and work on
Software documentation
Software documentation is an essential component of every software project, but it may
be a difficult undertaking. It is time-consuming, and tiresome occasionally, yet not an
exciting aspect of developing new software. Nonetheless, it is critical for getting your
business off onto the ground.
Don't rely on guessing or replicating what others have done when creating your
company's first or hundred pieces of software documentation. Poor documentation for
software can turn off potential clients while also wasting corporate resources. Instead,
use best practices such as utilizing inside experience and minimizing jargon to create
technical documentation that elevates rather than degrades your program.
Unit Testing
Unit testing involves the testing of each unit or an individual component of the software
application. It is the first level of functional testing. The aim behind unit testing is to
validate unit components with its performance.
A unit is a single testable part of a software system and tested during the development
phase of the application software.
The purpose of unit testing is to test the correctness of isolated code. A unit component
is an individual function or code of the application. White box testing approach used for
unit testing and usually done by the developers.
Whenever the application is ready and given to the Test engineer, he/she will start
checking every component of the module or module of the application independently or
one by one, and this process is known as Unit testing or components testing
Black box testing
Black box testing is a technique of software testing which examines the functionality of
software without peering into its internal structure or coding. The primary source of black
box testing is a specification of requirements that is stated by the customer.
In this method, tester selects a function and gives input value to examine its
functionality, and checks whether the function is giving expected output or not. If the
function produces correct output, then it is passed in testing, otherwise failed. The test
team reports the result to the development team and then tests the next function. After
completing testing of all functions if there are severe problems, then it is given back to
the development team for correction.
The term 'white box' is used because of the internal perspective of the system. The clear
box or white box or transparent box name denote the ability to see through the
software's outer shell into its inner workings
o Path testing
o Loop testing
o Condition testing
o Testing based on the memory perspective
o Test performance of the program
Path testing
In the path testing, we will write the flow graphs and test all independent
paths. Here writing the flow graph implies that flow graphs are
representing the flow of the program and also show how every program is
added with one another as we can see in the below image:
And test all the independent paths implies that suppose a path from
main() to function G, first set the parameters and test if the program is
correct in that particular path, and in the same way test all other paths
and fix the bugs.
Loop testing
In the loop testing, we will test the loops such as while, for, and do-while,
etc. and also check for ending condition if working correctly and if the size
of the conditions is enough.
For example: we have one program where the developers have given
about 50,000 loops.
1. {
2. while(50,000)
3. ……
4. ……
5. }
We cannot test this program manually for all the 50,000 loops cycle. So
we write a small program that helps for all 50,000 cycles, as we can see in
the below program, that test P is written in the similar language as the
source code program, and this is known as a Unit test. And it is written by
the developers only.
1. Test P
2. {
3. ……
4. …… }
As we can see in the below image that, we have various requirements
such as 1, 2, 3, 4. And then, the developer writes the programs such as
program 1,2,3,4 for the parallel conditions. Here the application contains
the 100s line of codes.
The developer will do the white box testing, and they will test all the five
programs line by line of code to find the bug. If they found any bug in any
of the programs, they will correct it. And they again have to test the
system then this process contains lots of time and effort and slows down
the product release time.
Now, suppose we have another case, where the clients want to modify the
requirements, then the developer will do the required changes and test all
four program again, which take lots of time and efforts.
In this, we will write test for a similar program where the developer writes
these test code in the related language as the source code. Then they
execute these test code, which is also known as unit test programs.
These test programs linked to the main program and implemented as
programs.
Therefore, if there is any requirement of modification or bug in the code,
then the developer makes the adjustment both in the main program and
the test program and then executes the test program.
Condition testing
In this, we will test all logical conditions for both true and false values;
that is, we will verify for both if and else condition.
For example:
1. if(condition) - true
2. {
3. …..
4. ……
5. ……
6. }
7. else - false
8. {
9. …..
10.……
11.……
12.}
The above program will work fine for both the conditions, which means
that if the condition is accurate, and then else should be false and
conversely.
Cyclomatic Complexity
Cyclomatic complexity is a software metric used to measure the complexity of a
program. Thomas J. McCabe developed this metric in 1976.McCabe interprets a computer
program as a set of a strongly connected directed graph. Nodes represent parts of the
source code having no branches and arcs represent possible control flow transfers during
program execution. The notion of program graph has been used for this measure, and it
is used to measure and control the number of paths through a program. The complexity
of a computer program can be correlated with the topological complexity of a graph.
V (G) = E - N + 2 * P
Example:
Code coverage is a metric that measures the percentage of a codebase executed during testing. It
helps to identify untested areas and improve software quality.In other words, it describes the degree
to which the coding of an application has been tested when a particular test suite runs. It is
considered one of the forms of White Box Testing and is usually performed by Developers during Unit
Testing.Code coverage scripts generate a report that lists how much of the application code has been
executed.
Mutation testing is a white box method in software testing where we insert errors
purposely into a program (under test) to verify whether the existing test case can detect
the error or not. In this testing, the mutant of the program is created by making some
modifications to the original program.
What is mutation?
The mutation is a small modification in a program; these minor modifications are planned
to typical low-level errors which are happened at the time of coding process.
Generally, we deliberate the mutation operators in the form of rules which match the
data and also generate some efficient environment to produce the mutant.
Mutation testing can be classified into three parts, which are as follows:
o Decision mutations
o value mutations
o Statement mutations
Backtracking
This technique involves the meticulous process of revisiting your code step by step to identify the sequence of
actions that led to a bug. Backtracking is particularly useful when the cause of the bug is unclear. By retracing
their steps, developers can gain insights into the code’s execution and understand the root of the issue.
Logging
Logging is a technique that incorporates strategically placed log statements within the code to capture the
program’s state, variable values, and execution flow. This method provides developers with a valuable tool for
understanding the sequence of events leading up to a bug. Analyzing logs can pinpoint the specific location of an
unexpected behavior, allowing your staff to find the right solution quickly.
Rubber Ducking
The name “rubber ducking” comes from the story of a programmer who would try to find the solution by
explaining his code to a rubber duck. Fortunately, you don’t need an actual rubber duck to use this strategy.
Instead, you can run through the exercise of explaining the code or problem aloud to an inanimate object or a
colleague. This method forces you to articulate your understanding of the problem, which can break you out of
your usual thought processes and take an objective view of the situation—which often leads to a solution.
Binary Search
Binary search is a powerful algorithmic technique that systematically narrows down the search space for a bug.
By strategically selecting test cases or input data, developers can efficiently identify the region of the code where
the bug is likely to be located. This technique is especially effective when dealing with large codebases.
Brute Force
Often used as a last resort debugging technique, brute force is a systematic approach that requires exhaustive
testing of different inputs or scenarios to identify the conditions triggering a bug. By continuously trying different
possibilities, developers can narrow down potential sources of the bug and eventually arrive at a solution.
However, this is typically the most tedious and time-consuming debugging technique in software testing.
Integration testing
Integration testing is the second level of the software testing process comes after unit
testing. In this testing, units or individual components of the software are tested in a
group. The focus of the integration testing level is to expose defects at the time of
interaction between integrated components or units.
Unit testing uses modules for testing purpose, and these modules are combined and
tested in integration testing. The Software is developed with a number of software
modules that are coded by different coders or programmers. The goal of integration
testing is to check the correctness of communication among all the modules.
System Testing
System Testing includes testing of a fully integrated software system. Generally, a
computer system is made with the integration of software (any software is only a single
element of a computer system). The software is developed in units and then interfaced
with other software and hardware to create a complete computer system. In other words,
a computer system consists of a group of software to perform the various tasks, but only
software cannot perform the task; for that software must be interfaced with compatible
hardware. System testing is a series of different type of tests with the purpose to
exercise and examine the full working of an integrated software computer system
against requirements.
Suppose we open an application, let say www.rediff.com, and there we can see that an
advertisement is displayed on the top of the homepage, and it remains there for a few
seconds before it disappears. These types of Ads are done by the Advertisement
Management System (AMS). Now, we will perform system testing for this type of field.
Regression testing is a type of software testing. Test cases are re-executed to check the
previous functionality of the application is working fine, and the new changes have not
produced any bugs.
Regression testing can be performed on a new build when there is a significant change in
the original functionality. It ensures that the code still works even when the changes are
occurring. Regression means Re-test those parts of the application, which are
unchanged.
Regression tests are also known as the Verification Method. Test cases are often
automated. Test cases are required to execute many times and running the same test
case again and again manually, is time-consuming and tedious too.
Software Reliability
Software Reliability means Operational reliability. It is described as the ability of a
system or component to perform its required functions under static conditions for a
specific period.
Software reliability is also defined as the probability that a software system fulfills its
assigned task in a given environment for a predefined number of input cases, assuming
that the hardware and the input are free of error.