Different modules specified in the design document are coded in the Coding phase according to the module specification. The main goal of the coding phase is to code from the design document prepared after the design phase through a high-level language and then to unit test this code.
Good software development organizations want their programmers to maintain some well-defined and standard style of coding called coding standards. They usually make their own coding standards and guidelines depending on what suits their organization best and based on the types of software they develop. It is very important for the programmers to maintain the coding standards otherwise the code will be rejected during code review.
These rules tell about which types of data that can be declared global and the data that can’t be.
All functions that encountering an error condition should either return a 0 or 1 for simplifying the debugging.
Code should be easily understandable. The complex code makes maintenance and debugging difficult and expensive.
Each variable should be given a descriptive and meaningful name indicating the reason behind using it. This is not possible if an identifier is used for multiple purposes and thus it can lead to confusion to the reader. Moreover, it leads to more difficulty during future enhancements.
The code should be properly commented for understanding easily. Comments regarding the statements increase the understandability of the code.
Lengthy functions are very difficult to understand. That’s why functions should be small enough to carry out small work and lengthy functions should be broken into small ones for completing small tasks.
GOTO statement makes the program unstructured, thus it reduces the understandability of the program and also debugging becomes difficult.
Unit testing is a software testing method in which individual components of the program, called units, are tested independently with all the required dependencies.
Unit testing is mostly done by the actual programmers, who write the programs for the units.
Automated execution and reporting of the outcome of test scenarios and cases. In most large and complex projects, many phases of the testing process are automated.
Sometimes the effort of automating the tests is so huge that there is a separate project for automation with a separate team dedicated to it, including a separate reporting structure with separate management.
Time and effort
As your codebase grows, the number of modules to be unit tested grows. Manual testing occupies a lot of days of the typical programmer’s calendar.
Accuracy
Test case execution is a rote and boring activity. Humans can make mistakes. However, an automated test suite will run and return the correct results every time.
Early bug reporting
Automating unit test cases gives you the distinct advantage of early reporting of bugs and errors.
Built-in support for unit testing
There are many programming languages that provide built-in support for writing unit tests by means of libraries dedicated to unit testing. Examples include Python, Java, and PHP.
# Function that receives two numbers and return the sum of the numbers
def add(x,y):
return x+y
# Function that receives two numbers and return the subtraction of the numbers
def substract(x,y):
return x-y
calc.py
import unittest
import calc
class TestCalc(unittest.TestCase):
def test_add(self):
result = calc.add(10,5)
self.assertEqual(result, 15)
test_calc.py
Instead of:
python .\test_calc.py
Run this:
python -m unittest test_calc.py
calc.py
Reference:
DocTest
def add(x,y):
"""return the sum of the numbers
>>> add(5,10)
16
>>> add(3,2)
5
"""
return x+y
def substract(x,y):
"""return the subtraction of the numbers
>>> substract(5,10)
-5
>>> substract(3,2)
1
"""
return x-y
if __name__ == "__main__":
import doctest
doctest.testmod()
python .\calc.py
PS C:\Users\illamas\pythonUnitTest>
python .\calc.py
**********************************************************************
File ".\calc.py", line 5, in __main__.add
Failed example:
add(5,10)
Expected:
16
Got:
15
**********************************************************************
1 items had failures:
1 of 2 in __main__.add
***Test Failed*** 1 failures.
DocTest
Reference:
Factorial
3 -> 6
5 -> 120
Palindrome
oso = True
anita lava la tina = True
osa = False
How many digits are inside of a number (Not cast to string, use it as integer)
303,3 -> 2
22432782,2 -> 4
Include the unit tests also add negative cases
Static Analysis
A way for developers to test their code without actually executing it — is called a non-run-time environment. Static code analysis tools offer an incredibly efficient way to find programming faults and display them to software engineers.
Static analysis is generally considered the more thorough way to analyze code. It also has the potential to be the more economical option. Identifying code errors in the early stages means that they are typically less expensive to fix than errors that become stuck in the system.
Dynamic Analysis
Then there’s dynamic code analysis, a way to test code while it’s being executed on a real or virtual processor. It’s especially effective for finding subtle defects or vulnerabilities because it looks at the code’s interaction with other databases, servers, and services.
However, dynamic analysis comes with some important caveats. For example, it will only find faults in the specific excerpt of the code that’s being executed – not the entire codebase. On the other hand, some errors not found by static analysis would show up clearly in a dynamic test, especially those related to parts of the source code that rely on external services.
To achieve the highest possible level of test coverage, it’s recommended to combine the two methods.
pip install pylint
python -m pip install pylint
sum1 = 3 + 4;
print("Sum is %d."; % sum1)
# Sum is 7.
pylint my_sum.py
my_sum.py:1:0: W0301: Unnecessary semicolon
Source: IEEE Std. 730-2014 (IEEE, 2014)
Software quality is:
The degree to which a software product meets established requirements; however, quality depends upon the degree to which established requirements accurately represent stakeholder needs, wants, and expectations.
Source: IEEE Std. 730-2014
Software quality assurance is:
A set of activities that define and assess the adequacy of software processes to provide evidence that establishes confidence that the software processes are appropriate for and produce software products of suitable quality for their intended processes. A key attribute of SQA is the objectivity of the SQA function with respect to the project. The SQA function may also be organizationally independent of the project, that is, free from technical, managerial, and financial pressures from the project.
Ensuring an acceptable level of confidence that the software product and software operation services will conform to functional technical requirements and be suitable quality for its intended use.
According to the extended SQA definition – ensuring an acceptable level of confidence that the software development and software operation process will conform to scheduling and budgetary requirements.
Initiating and managing activities to improve and increase the efficiency of software development, software operation, and SQA activities. These activities yield improvements to the prospects' achieving of functional and managerial requirements while reducing costs.
Source: ISO/IEC/IEEE Std. 90003:2014 (ISO/IEC/IEEE, 2014)
Software product is
Set of computer programs, procedures, and possibly associated documentation and data.
Source: after ISO 9000:2000 (ISO, 2000)
Source: after ISO 9000:2000 (ISO, 2000)
IEEE Definitions
According to McCall's model, five software quality factors are included in the product operation category, all of which deal with requirements that directly affect the daily operation of the software
Affect the complete range of software maintenance activities: corrective maintenance (correction of software faults and failures), adaptive maintenance (adapting the current software to additional circumstances and customers without changing the software), and perfective maintenance (enhancement and improvement of existing software with new applications with respect to relevant developments of products, services, and new government regulations and their impact etc.).
Three quality factors are included in the product transition category, a category that pertains to the adaptation of software to other environments, and its interaction with other software systems.
Search at least 2 factors in each of the categories for McCall's model. Add an example
Source: The ISO/IEC 25010:2011
The ISO/IEC 25010 quality model
(For factors not included in McCall's and ISO/IEC 25010:2011 product quality models.)
Additional software quality factors additional to McCall's factors
1 | Effectiveness |
2 | Evolvability |
3 | Expandability |
4 | Extensibility |
5 | Human Engineering |
6 | Manageability |
7 | Modifiability |
8 | Productivity |
9 | Safety |
10 | Satisfaction |
11 | Supportability |
12 | Survivability |
13 | Understandability |
14 | Verifiability |
OWASP stands for the Open Web Application Security Project, an online community that produces articles, methodologies, documentation, tools, and technologies in the field of web application security.
Pick two categories, search descriptions, examples and sites that were hacked with this attack
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. So ideally, we can place any file in the computer on version control.
Git is a Distributed Version Control System. So Git does not necessarily rely on a central server to store all the versions of a project’s files. Instead, every user “clones” a copy of a repository (a collection of files) and has the full history of the project on their own hard drive. This clone has all of the metadata of the original while the original itself is stored on a self-hosted server or a third party hosting service like GitHub.
https://learning.oreilly.review/library/view/python-unit-test/9781484226766/A436414_1_En_2_Chapter.html
from Python Unit Test Automation: Practical Techniques for Python Developers and Testers
https://blog.codacy.com/everything-you-need-to-know-about-static-code-analysis/
https://learning.oreilly.com/library/view/software-quality/9781119134497/c01.xhtml#c01anchor-1
from Software Quality by Daniel Galin Publisher: Wiley-IEEE Computer Society Press
https://sucuri.net/guides/owasp-top-10-security-vulnerabilities-2021/
https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/