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

Soft Engg 5

The document discusses coding and testing practices in software engineering. It covers topics like coding standards, code review approaches, unit testing types and advantages/disadvantages.

Uploaded by

tapstaps902
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)
14 views

Soft Engg 5

The document discusses coding and testing practices in software engineering. It covers topics like coding standards, code review approaches, unit testing types and advantages/disadvantages.

Uploaded by

tapstaps902
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/ 12

SOFTWARE ENGINEERING

UNIT – V
CODING & TESTING
 CODING

● The coding is the process of transforming the design of a system into a computer
language format.

● This coding phase of software development is related with software translating design
specification into the source code.

● It is necessary to write source code & internal documentation so that conformance


of the code to its specification can be easily verified.

● Coding is done by the coder or programmers who are independent people than the
designer.

Goals of Coding

To translate the design of system into a computer language format: The coding is
the process of transforming the design of a system into a computer language format,
which can be executed by a computer and that perform tasks as specified by the design
of operation during the design phase.

Making the program more readable: Program should be easy to read and
understand. It increases code understanding having readability and understandability
as a clear objective of the coding activity can itself help in producing more maintainable
software.

Coding Standards

● Package names should be in lowercase (e.g., mypackage, edu.iitk.maths).

● Type names should be nouns and should start with uppercase (e.g., Day,
DateOfBirth, EventHandler).

● Variable names should be nouns starting with lowercase (e.g., name, amount).

1
● Constant names should be all uppercase (e.g., PI, MAX ITERATIONS).

● Method names should be verbs starting with lowercase (e.g., getValue()).

● Private class variables should have the suffix (e.g., “private int value ”).

● Variables with a large scope should have long names; variables with a small scope
can have short names; loop iterators should be named i, j, k, etc.

● Exception classes should be suffixed with Exception (e.g., OutOfBoundException).

Files

● Java source files should have the extension .java—this is enforced by most compilers
and tools.

● Each file should contain one outer class and the class name should be the same as
the file name.

● Line length should be limited to less than 80 columns and special characters should
be avoided. If the line is longer, it should be continued and the continuation should
be made very clear.

Statements

● Variables should be initialized where declared, and they should be declared in the
smallest possible scope.

● Declare related variables together in a common statement. Unrelated variables


should not be declared in the same statement.

● Class variables should never be declared public.

● Use only loop control statements in a for loop.

● Loop variables should be initialized immediately before the loop.

● Avoid the use of break and continue in a loop.

 CODE REVIEW

● Code Review is a systematic examination, which can find and remove the weak points
in the code such as memory leaks and buffer overflows.

2
● Technical reviews are well documented and use a well-defined defect detection
process that includes peers and technical experts. It is ideally led by a trained
moderator, who is NOT the author.

● This kind of review is usually performed as a peer review without management


participation. Reviewers prepare for the review meeting and prepare a review report
with a list of findings.

● Reviewers can be from any team or group as long as they’re a domain expert. If the
lines of code cover more than one domain, two experts should review the code.

benefits of code reviews

1) Share knowledge: Code reviews help junior developers learn from more senior team
members. Everyone has the ability to review and offer feedback. Shared knowledge
also helps team members take vacation, because everyone on the team has
background knowledge on a topic.

2) Discover bugs earlier: Rather than discovering bugs after a feature has been
shipped and scrambling to release a patch, developers can immediately find and fix
problems before customers ever see them. Moving the review process earlier in the
software development lifecycle through unit tests helps developers work on fixes with
fresh knowledge.

3) Enhance security: Code reviews create a high level of security, especially when
security professionals engage in a targeted review. Security team members can review
code for alert developers to the threat. Code reviews are a great complement to
automated scans and tests that detect security vulnerabilities.

4) Increase collaboration: When team members work together to create a solution,


they feel more ownership of their work and a stronger sense of belonging. Authors
and reviewers can work together to find the most effective solutions to meet customer
needs.

5) Improve code quality: Code reviews are an important way to ensure you ship high-
quality code and quality software.

3
Four approaches to code review

1) Pair programming

● Pair programming involves two developers collaborating in real time — one writing
code (the driver) and one reviewing code (the navigator).

● Pairing sessions are popular with development teams because teammates collaborate
to identify the most effective solution to a challenge. Team members share knowledge
and can quickly overcome difficulties by working through ideas together and drawing
on their expertise.

2) Over-the-shoulder reviews

● In an over-the-shoulder-review, two developers — the author and reviewer — team


up in person or remotely through a shared screen and the author explains the
completed change proposal and offers reasoning for the chosen solutions.

● The reviewer asks questions and makes suggestions, similar to how team members
collaborate during pairing sessions. The author can make small changes during the
review and note larger fixes for a later time.

3) Tool-assisted reviews

Automated tooling is an effective way to enforce code standards, identify vulnerability,


gather metrics, and gather files, but some teams may be tempted to completely rely on
tooling and forgo team member involvement to conduct code reviews.

4) Email pass-around

Email pass-arounds are often used for minor difficulties and small pieces of code. They
can be conducted via email or source code management systems. During an email
pass-around, an author sends an email containing code changes to reviewers.

 UNIT TESTING

● Unit testing is a type of software testing that focuses on individual units or


components of a software system.

4
● The purpose of unit testing is to validate that each unit of the software works as
intended and meets the requirements. Unit testing is typically performed by
developers, and it is performed early in the development process before the code is
integrated and tested as a whole system.

● Unit tests are designed to validate the smallest possible unit of code, such as a
function or a method, and test it in isolation from the rest of the system.

● This allows developers to quickly identify and fix any issues early in the development
process, improving the overall quality of the software and reducing the time required
for later testing.

Advantages of Unit Testing:

1) Unit testing allows the programmer to refine code and make sure the module works
properly.

2) Unit testing enables testing parts of the project without waiting for others to be
completed.

3) Unit testing allows developers to detect and fix issues early in the development
process, before they become larger and more difficult to fix.

4) Unit testing helps to ensure that each unit of code works as intended and meets the
requirements, improving the overall quality of the software.

5) Unit testing enables developers to work faster and more efficiently, as they can
validate changes to the code without having to wait for the full system to be tested.

Disadvantages of Unit Testing:

1) The process is time-consuming for writing the unit test cases.

2) Unit Testing will not cover all the errors in the module because there is a chance of
having errors in the modules while doing integration testing.

3) Unit Testing is not efficient for checking the errors in the UI(User Interface) part of
the module.
5
4) It requires more time for maintenance when the source code is changed frequently.

5) Unit testing can be challenging when dealing with complex units, as it can be

Types of Unit Testing:

1) White box testing


2) Black box testing
3) Gray box testing

1) White-Box Testing

White-box testing is the detailed investigation of internal logic and structure of the
code. White-box testing is also called glass testing or open-box testing. In order to
perform white-box testing on an application, a tester needs to know the internal
workings of the code.

Advantages of White Box testing:

1) Testing can commence even before the GUI is ready.


2) As internal functionality is considered, all the possible conditions are considered
and test cases are generated. Hence all the functionalities are being tested.

3) It identifies the specific procedure accuracy within the application.

4) It minutely verifies whether the program can be successfully executed with other
parts of the application.

5) It identifies error in the hidden code and thus makes debugging process swift.

Disadvantages of White Box testing:

1) As the internal code of the application has to be considered while preparing the test
cases, skilled testers are required who have knowledge of programming also. Hence
the cost of the resources is high.

2) It is not possible for the tester to look into every bit of the code and identify the
hidden errors. This may result in failure of the application.

3) Sometimes a change in the code may be required and thus all the scenarios may
need to be tested again.

6
4) White box testing is an exhaustive method.

5) It takes time to tester to develop the test cases.

2) Black-Box Testing

● The technique of testing without having any knowledge of the interior workings of
the application is called black-box testing. The tester is oblivious to the system
architecture and does not have access to the source code.

● Typically, while performing a black-box test, a tester will interact with the system's
user interface by providing inputs and examining outputs without knowing how and
where the inputs are worked upon.

Advantages of Black Box Testing

1) Efficient when used on large systems.

2) Since the tester and developer are independent of each other, testing is balanced
and unprejudiced.

3) Tester can be non-technical.

4) There is no need for the tester to have detailed functional knowledge of system.

5) Tests will be done from an end user's point of view, because the end user should
accept the system. (This testing technique is sometimes also called Acceptance
testing.)

Disadvantages of Black Box Testing:

1) Test cases are challenging to design without having clear functional specifications.

2) It is difficult to identify tricky inputs if the test cases are not developed based on
specifications.

3) It is difficult to identify all possible inputs in limited testing time. As a result, writing
test cases may be slow and difficult.

4) There are chances of having unidentified paths during the testing process.

5) There is a high probability of repeating tests already performed by the programmer.

7
3) Grey-Box Testing

● Grey-box testing is a technique to test the application with having a limited


knowledge of the internal workings of an application.

● In grey-box testing, the tester has access to design documents and the database.
Having this knowledge, a tester can prepare better test data and test scenarios while
making a test plan.

Advantages of Gray Box Testing:

1) Users and developers have clear goals while doing testing.


2) Gray box testing is mostly done by the user perspective.
3) Testers are not required to have high programming skills for this testing.
4) In gray box testing, developers have more time for defect fixing.
5) Gray box testing is unbiased. It avoids conflicts between a tester and a developer.

Disadvantages of gray box testing:

1) Defect association is difficult when gray testing is performed for distributed


systems.
2) Limited access to internal structure leads to limited access for code path traversal.
3) Because source code cannot be accessed, doing complete white box testing is not
possible.
4) Gray box testing is not suitable for algorithm testing.
5) Most of the test cases are difficult to design.

 INTEGRATION TESTING

● Integration testing is a type of software testing that verifies that different components
of a system work together as expected. It is typically done after unit testing and before
system testing.

● The goal of integration testing is to identify any issues that may arise when different
components are combined, such as conflicts or data integrity problems.

● This type of testing can be done in a variety of ways, such as by testing individual
modules together or by testing the entire system as a whole.

8
Types of integration testing

There are four basic approaches to integration testing:

1. Big Bang

In Big Bang integration testing, all the components are integrated and tested together
in one go.

2. Top Down

Top-Down integration testing involves testing top-level units first and then moving on
to testing lower-level units.

3. Bottom up

Bottom-up integration testing involves testing the lower-level modules first. These tests
are then used to test higher level modules until all the modules are tested.

4. Sandwich testing

Sandwich integration testing is a combination of the Top Down and Bottom Up


approaches.

Advantages of integration testing:

1) It is convenient for small systems.


2) Simple and straightforward approach.
3) Can be completed quickly.
4) Does not require a lot of planning or coordination.
5) May be suitable for small systems or projects with a low degree of interdependence
between components.

Disadvantages of integration testing:

1) There will be quite a lot of delay because you would have to wait for all the modules
to be integrated.
2) High risk critical modules are not isolated and tested on priority since all modules
are tested at once.
3) Not Good for long Projects.
4) High risk of integration problems that are difficult to identify and diagnose.
5) Can result in long and complex debugging and troubleshooting efforts.

9
 SYSTEM TESTING

● System testing is a type of software testing that evaluates the overall functionality
and performance of a complete and fully integrated software solution. It tests if the
system meets the specified requirements and if it is suitable for delivery to the end-
users.

● System Testing is basically performed by a testing team that is independent of the


development team that helps to test the quality of the system impartial.

System Testing Process:

● Test Environment Setup: Create testing environment for the better-quality testing.

● Create Test Case: Generate test case for the testing process.

● Create Test Data: Generate the data that is to be tested.

● Execute Test Case: After the generation of the test case and the test data, test cases
are executed.

● Defect Reporting: Defects in the system are detected.

● Regression Testing: It is carried out to test the side effects of the testing process.

● Log Defects: Defects are fixed in this step.

● Retest: If the test is not successful then again test is performed.

Types of System Testing:

1) Performance Testing: Performance Testing is a type of software testing that is


carried out to test the speed, scalability, stability and reliability of the software product
or application.

2) Load Testing: Load Testing is a type of software Testing which is carried out to
determine the behavior of a system or software product under extreme load.

3) Stress Testing: Stress Testing is a type of software testing performed to check the
robustness of the system under the varying loads.

10
4) Scalability Testing: Scalability Testing is a type of software testing which is carried
out to check the performance of a software application or system in terms of its
capability to scale up or scale down the number of user request load.

Advantages of System Testing:

 Verifies the overall functionality of the system.


 Detects and identifies system-level problems early in the development cycle.
 Helps to validate the requirements and ensure the system meets the user needs.
 Improves system reliability and quality.
 Facilitates collaboration and communication between development and testing
teams.

disadvantages of System Testing:

 Can be time-consuming and expensive.


 Requires adequate resources and infrastructure.
 Can be complex and challenging, especially for large and complex systems.
 Dependent on the quality of requirements and design documents.
 Limited visibility into the internal workings of the system.

 PROGRAM ANALYSIS TOOLS

● A program analysis tool means an automated tool that takes the source code or the
executable code of a program as input and produces reports regarding several
important characteristics of the program, such as its size, complexity, adequacy of
commenting, adherence to programming standards, etc.

There are two categories of program analysis tools:

1) Static Program Analysis Tool:

● Static Program Analysis Tool is that evaluates and computes various characteristics
of a software product without executing it.

● Normally, static program analysis tools analyze some structural representation of a


program to reach a certain analytical conclusion. Basically, some structural properties
are analyzed using static program analysis tools.

11
2) Dynamic Program Analysis Tool:

● Dynamic Program Analysis Tool that require the program to be executed and its
actual behavior to be observed.

●A dynamic program analyzer basically implements the code. It adds additional


statements in the source code to collect the traces of program execution.

● When the code is executed, it allows us to observe the behavior of the software for
different test cases.

● Once the software is tested and its behavior is observed, the dynamic program
analysis tool performs a post execution analysis and produces reports which describe
the structural coverage that has been achieved by the complete testing process for the
program.

12

You might also like