Programmers must use defensive design to make sure that their program is robust against possible misuse
Example of misuse could be brute force attack
This could be easily prevented by the programmer implementing a maximum amount of times a user can enter data, e.g. the program exits when the wrong data is entered too many times.
Authentication is a coding method to check that a user is who they say they are and allowed to accesses the program.
This could be by asking the user to enter a user name and password which is compared against a stored user name and password.
If they match then the user is authenticated.
Authentication could include fingerprint scans or face ID
Authentication can also be physical
This is know as 2-factor authentication which may include the following:
Temporary access key code
Automated phone call to confirm your identity (bank)
Input validation is the process by which the computer checks that the data entered by a user meets certain criteria before it is processed. This helps to prevent errors and improve the security program.
For example, a user is asked to enter a mobile phone number but only enters 9 digits.
A standard UK mobile number is 11 digits.
A length check validation can be used to ensure that 11 digits are entered.
The last one or two digits in a code are used to check the other digits are correct
Checks the data is in the right format
Checks data isn't too short or too long
Looks up acceptable values in a table
Checks that data has been entered into a field
Checks that the value falls within the specific range
Looks up words in a dictionary
The maintainability of a programme refers to the ability for the programme to be easily understood, modified, repaired or enhanced.
Methods of maintainability:
Use of sub programs
Indentation
Naming conventions
Commenting
Sub-programs, are separate pieces of code that can be called from within a program to perform specific tasks. By breaking down a program into smaller sub-programs, it becomes easier to maintain because:
Sub-programs can be tested and debugged separately, which can make finding and isolating errors quicker and easier.
Sub-programs can be reused in multiple parts of the code, which can reduce the amount of duplicate code and make the program more efficient.
Sub-programs can be modified or updated without affecting the rest of the program, which can make it easier to add new features or fix issues without causing any negative consequences for the rest of the code.
The 2 main types of sub programs:
Procedure
Function
Indentation improves a program's maintainability by making the code structure more understandable and easier to read. It helps programmers understand how code blocks are related to each other and makes it easier to identify errors in the program's logic.
In Python, indentation is needed to show the scope of sections of code, and is a syntax rule of the language
However, in other languages, it is not a rule and more of a convention
To make code easier to follow, programmers follow standard conventions.
E.g.
name = input("Enter name")
car_age = int(input("Enter the age of the car"))
Comments in programs serve a number of purposes:
To inform them reader of a bug or issues
To explain the code and its function in more detail
To stop a line of section of code from executing
They make the code more readable and understandable for other developers who may work on the same code in the future.
Common symbols used for commenting are //, /**, ‘, #, */,
Art style for this page - Oil pastel