Flashcards
5. Writing maintainable programs
Flashcards do conjunto (12)
- 1What is a variable?It is a value that can be changed while the program is running
- 2What is a constant?A value that cannot be changed while the program is running
- 3What is an identifier?The name given to a variable, constant, controller... (e.g. score)- can't be reserved words
- 4What are reserved words?words specific to the program to tell it what to do- e.g. IF, FOR, WHILE, CHAR
- 5What is the need for good programing writing techniques?1) comments- explanations of what the line does- makes the program more understandable
2) indentations- spacing- looks neater, standard techniques, everyone gets it
3) good identifiers- meaningful names- less errors- less confusion
4) subroutines- parts of program- easier to make program- less cluter - 6How to declare a variable?1) Name, 2) Data type, 3) Scope- Local declared within a subroutine or global declared at start can be used throughout program
- 7Why should a variable be declared?So translator can reserve memory space for it and doesn't think it is a reserved word (variable can't have the same name as a reserved word)
- 8How to write a meaningful identifieruse short descriptive names, no space ( use _), no reserved words, conventions: sentence case, camelcase (capitalise starting length), including type of variable, hungarian notation (txtScore)
- 9How do consonants help to improve maintainability?It can be understood by everyone rather than using actual value so anyone can maintain program (gravity is understood better than 9.81)
- 10How to initialise a variableThey need to have a starting value so that it is reset each time the program starts- Numeric- 0, String- “”, Boolean- False
- 11Why and how to annotate codescomments used so program can be understood in the future or by someone else so that it can be maintained. Header comment- used at the start name, what program does, programmer name, date, notes on errors or current work. Subroutines- what it does, parameters. Purpose of variables and constants. Each line of code explained.
- 12Why indent and format code structure?Indenting- at the end of each code structure- shows where each code starts and finishes.
Formatting- codes should be grouped in logical blocks, add a blank line underneath.
Makes it easy to maintain and understand.
Informações
- Descrição
- A levels Flash cards FlashCards sobre 5. Writing maintainable programs, criado por deepi1k73 em 24-05-2014.
- Criado por
- deepi1k73
- Visualizações
- 27
- Avaliação