T2 Homework 2
T2 Homework 2
if not validUsername(uName)
print("That isn't a valid username")
endif
(b) A programmer says that they need to add authentication to the algorithm.
Explain what is meant by authentication in this situation.
Making sure the user is who they say they are by adding passwords and usernames etc. It
would also be checking to see if the passwords and suernames fit the criteria to ensure security.
1
Homework 2 Defensive design
Unit 8 Logic and languages
(c) Explain three techniques that have been used in the program to make it
more maintainable.
Technique 1:
Creating a variable that could return false or true depending on the outcome rather than a
direct return which allows for the return value to be changed or modified for other purposes.
Technique 2:
Creating a seperate function which can be edited and removed and this allows for variables
to remain local and for the code to be easier to read and change.
Technique 3:
Using two different variable names for inside the function and outside it as if you want to
declare one of them to be global, this allows for that possibility without tampering with the
outside code.
(d) Explain one other technique that could be used in the program to make it more
maintainable.
Creating variable names for the upper and lower boundaries as that would make it easier to
change them rather then setting them as hard values.
[Total 12 marks]