Producing robust programs
What is Defensive Design?
Means that all possible contingencies are planned for including accidental or deliberate incorrect inputs or menu option selection
Producing robust programs
What is this?
Means that all possible contingencies are planned for including accidental or deliberate incorrect inputs or menu option selection
Defensive Design
It ensures that
Errors / bugs are kept to a minimum
Programs behave as expected even if the user does something unexpected
All possible errors that could occur are identified and catered for
Producing robust programs
What does Defensive Design try to ensure?
Errors / bugs are kept to a minimum
Programs behave as expected even if the user does something unexpected
All possible errors that could occur are identified and catered for
Producing robust programs
Defensive Design
What is Input Sanitisation?
* Converting user input so that it is all one case, e.g. upper case
Producing robust programs
Defensive Design
What does this describe?
• Removing ‘white space’ from user input
• Converting user input so that it is all one case, e.g. upper case
Input Sanitisation
Producing robust programs
Defensive Design
What is Validation?
Producing robust programs
Defensive Design
What is :
Validation
Producing robust programs
Defensive Design
What is Authentication?
Producing robust programs
Defensive Design
What is this?
Authentication
Producing robust programs
Defensive Design
How should you plan for contingencies? (4 things)
Producing robust programs
Defensive Design
What is this called?
planning for contingencies
Producing robust programs
Maintainability
Why do programmes need to be easy to maintain?
So if you return to code to, for example, add more features, you can understand what you did
So people who you are working with can pick up your code and easily work with and understand what you have done
Producing robust programs
What are these?
So if you return to code to, for example, add more features, you can understand what you did
So people who you are working with can pick up your code and easily work with and understand what you have done
reasons why programmes need to be easy to maintain
Producing robust programs
Maintainability
How can programmers ensure the code they write is easy to maintain?
Use comments to:
• Explain the purpose of the program
• Explain sections of code
• Explain unusual approaches
• Visually divide sections of a program
Use whitespace to make sections of a program easier to see
Use indentations for every selection and iteration branch
Use descriptive variable names and explain their purpose with a comment
Use procedures and functions to:
• Structure the code
• Eliminate duplicate code
Use constants declared at the top of a program
Producing robust programs
Maintainability
What are these?
Use comments to:
• Explain the purpose of the program
• Explain sections of code
• Explain unusual approaches
• Visually divide sections of a program
Use whitespace to make sections of a program easier to see
Use indentations for every selection and iteration branch
Use descriptive variable names and explain their purpose with a comment
Use procedures and functions to:
• Structure the code
• Eliminate duplicate code
Use constants declared at the top of a program
ways programmers can ensure the code they write is easy to maintain
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
comments (4 things)
Use comments to: • Explain the purpose of the program • Explain sections of code • Explain unusual approaches • Visually divide sections of a program
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
White space
Use whitespace to make sections of a program easier to see
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
Indentations
Use indentations for every selection and iteration branch
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
Descriptive variable names
Use descriptive variable names and explain their purpose with a comment
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
Procedures and functions
Use procedures and functions to:
• Structure the code
• Eliminate duplicate code
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
constants
Use constants declared at the top of a program
Producing robust programs
Maintainability
How can the following help programmers ensure the code they write is easy to maintain?
constants
Use constants declared at the top of a program
Producing robust programs
Testing
Four main reasons why a program should be thoroughly tested before being given to a user
1) To ensure there are no bugs or errors in the code
2 To ensure the program has an acceptable performance and usability
3) To ensure that unauthorised access is prevented
4) To ensure that the program meets the requirements
Producing robust progroams
What are these?
1) To ensure there are no bugs or errors in the code
2 To ensure the program has an acceptable performance and usability
3) To ensure that unauthorised access is prevented
4) To ensure that the program meets the requirements
Four main reasons why a program should be thoroughly tested before being given to a user