Knowledge organisersDefensive Design
Understand why each of the identified maintainability techniques are useful and apply this appropriately
Maintainability refers to how easy it is to understand, update, and fix a program after it has been written. Good maintainability practices include using sub-programs to break code into manageable sections, following clear naming conventions for variables and functions, using proper indentation, and adding comments to explain the code.
totalPrice not tp, position not p.PI = 3.142, MAX_POSITION = 512) so they can be 'updated once and it updates throughout'.# POOR maintainability
x = float(input("Enter value: "))
y = float(input("Enter value: "))
z = x / y
print(z)
# GOOD maintainability
# Calculate speed from distance and time
distance = float(input("Enter distance (m): "))
time = float(input("Enter time (s): "))
speed = distance / time # speed = distance / time
print("Speed: " + str(speed) + " m/s")