Writing Maintainable code

Descrição

Dope , hella accurate awesome flash cards by yours truly
Ron Wabe
FlashCards por Ron Wabe, atualizado more than 1 year ago
Ron Wabe
Criado por Ron Wabe mais de 9 anos atrás
20
0

Resumo de Recurso

Questão Responda
Define constant. A name used to refer to a fixed value. The value must be set when the code is written. It cannot be changed while the program is running.
Define variable An identifier name that refers to a particular memory location that is used to store data. The value of the data that is stored can be changed when the program is running.
What is a global variable? Declared at the beginning of the program. It can then be used in all subroutines in the program.
What is a local variable? Declared within a subroutine and can only be used in that subroutine.
What is an identifier? The name given to a variable, constant or subroutine is called it's identifier.
What is a reserved word/keyword? Words that have a specific purpose in a programming language. These CANNOT be used as identifiers.
What are the differences between constants and variables? 1. When a constant is declared it must be given an actual value, variables can be left empty initially. 2. A constant must remain the same during the running of a program, a variable can change.
What does 'initialising variables' mean? - Initialising means a variable is given a starting value. - Initialising variables makes the code easier to follow.
How can you use constants to maintain a program? - Using a descriptive identifier for the constant makes the code clearer to read which makes it easier to maintain. - It is easier to remember the identifier than the value when writing the code. - If the value needs to be changed then you can change the value on the line where it is being declared and this updates the value throughout the program.
When naming constants and variable, what should you do? 1. Identifier names should describe the item identified. 2. Declarations of variables/constants should be commented to explain their purpose. 3. Standard conventions include using underscores. 4. Keywords of the language cannot be used as the translator will produce a syntax error. 5. Variables/constants should be declared as possible wherever possible.
How can you lay out code to make it more maintainable? 1. Organising code into modules. 2. Using indentation to show control structures easily. 3. Using white space to format the code into logical groups statements. 4. Adding comments to describe what different parts of the code do.
Why should programmers use these programming techniques? 1. It enables a team of programmers to work together on a program and understand each others code. 2. If everyone follows the same convention then all modules will match and other programmers can read it/ maintain it later on. 3. Indentation shows the structure of the code e.g. where IF statements start and end. 4. Meaningful identifiers make the code easier to understand. 5. Code that is split into modules is easier to debug and read in general. 6. Comments make it easier to trace the logic of the program and find where errors occur.

Semelhante

Computing Hardware - CPU and Memory
ollietablet123
GCSE Biology B2 (OCR)
Usman Rauf
AS Chemistry - Enthalpy Changes
Sarah H-V
Biology B1.1 - Genes
raffia.khalid99
Unit 1 flashcards
C R
Cell Structure
megan.radcliffe16
Exchange surfaces and breathing
megan.radcliffe16
C1 Quiz
Leah Firmstone
OCR GCSE History-Paper Two: The Liberal Reforms 1906-14 Poverty to Welfare State NEW FOR 2015!!!
I Turner
Biology B1.3
raffia.khalid99
OCR Physics P4 Revision
Dan Allibone