Mapa mental
5. Writing maintainable programs
Contenido del mapa
5. Writing maintainable programs
define terms
- variable- a value that can change while the program running
- constant- a value that cannot change when the program is running
- identifier- a name given to controls, variables...
- reserved words/ keyword- words that are specified by the program to tell it to do a function, e.g. If, Else, Char
good program-writing techniques
- suitable identifiers
- easy to understand
- less errors- can trace variables- can spot them
- sensible name: Hungarian Notation- txtScore, Camel case- uses capital letters or underscores- there are no spaces
- subroutines
- breaks the program- easier to make
- general advantages of a subroutine...
- indentation
- standard techniques mean that everyone can understand it
- indent at the start and end of each code structure
- easier and clear to understand
- know where each structure starts and ends
- comments
- need to understand it in the future or if someone else looks at it
- easy to maintain
- easy to find and correct errors
- Header comment- at beginning- contains name, what program does, programmers name, date, errors
- Subroutines need a comment- explain what it does, how it will be called, parameter needed
- explain purpose of variables and constants and explain lines of codes (come before the code)
- formating- code should be grouped in logical blocks- have blank lines between them
- suitable identifiers
modularised programs
- look back at 3.2.1
- each module is made into a subroutine; this means that different programer can work on the same program
declare variables and constants
- how to declare variables and then afterwards
- data type
- a suitable name- use descriptive names so that it is easy to understand, no spaces (uses underscores), don't use reserved words
- scope
- local variable- used only in the subroutine it is declared
- global variable- can be used anywhere in the program
- initialise after declaring, restarts variables when program starts again, number-0, bool-False, string -""
- why declare them?
- translator can save memory for them
- translator does not think it is a reserved word
- Conventions for naming
- used to show data type or enhance readability
- These can be: sentence case, camel case, including type of variable (intAge), include local variable or not, Hungarian notion
- constants
- data that stays the same throughout the program
- need to declare it because it needs to be understood by everyone, the actual data might have no meaning to someone else, e.g. gravity is easy to understand unlike 9.81
- how to declare variables and then afterwards
Información
- Descripción
- A levels Computing Mapa Mental sobre 5. Writing maintainable programs, creado por deepi1k73 el 14/04/2014.
- Creado por
- deepi1k73
- Visitas
- 24
- Valoración