String handling, arithmetic and operators
Throughout technical documentation, it is important to give examples and explain how and why you used string handling technique, basic arithmetic and logical and relational operators.
Basic arithmetic
- addition
- subtraction
- multiplication and division
- powers
- modular arithmeticModular arithmetic is a form of arithmetic dealing with remainders after integers are divided by a fixed 'modulus'.
Logical and relational operators
- equal to/not equal to
- <, >, < =, >=
- AND, OR and NOT
Organising Your work
Your Controlled Assessment will be a significant program. As programs grow and develop they often become unwieldy and complex. It is important that you write manageable and maintainable code.
How to manage code
- Use good indentation 鈥 it is helpful to see where structures start and end
- Use good formatting 鈥 put spaces around operators but not between brackets and functions
- Use blank lines between structures or sections of code
- Use camel case or snake case for function and variable names 鈥 ThisIsCamelCase, this_is_snake_case
- Use meaningful variable names
- Use only one statementThe smallest element of a programming language which expresses an action to be carried out. per line
- Keep code style consistent throughout
Comments
It is very important to comment code. You do not need to comment every line of code, but you should write enough comments to help other programmers (and yourself) understand what is going on.
Scripts
As your program develops, it may be easier to work with multiple scripts and import them into a main program. Group similar functions together. For exmple, you may want to group all validation functions together in one script and all file handling functions in another, allowing them to be reused and imported into other programs.
Python implementation
'''
GCSE Digital Technology
Maths Quiz
'''
from validateScript import * #import functions from other scripts
from gameEngine import *
from fileHandling import *
##############
#MAIN PROGRAM#
##############
if __name__ =="__main__":
#test runs
name = validateName()
quizCreator(menuSelection())
#choice returned from menuSelection function passed to quizCreator function
saveScore(name, score)
There are now four scripts. Two scripts for validating, the script for the main game engine and the script for file handling modules are imported into the main program.
C# Implementation
In one C# class, the program has been subdivided into multiple methods. The IDE allows for these to be collapsed so we can see an overview of the imported components and the method names (along with their parameter lists):
using System;
using System.IO;
namespace ConsoleApp1
{
class Program
{
// Score managed as a global variable
static int score = 0;
static void Main(string[] args)...
static void saveStrong(String playerName, int playerScore)...
static void quizCreator(int diff)...
static bool validateName(String nameToBeTested)...
static int showTheMenu()...
static void addQuestion()...
static void subQuestion()...
}
}
Review
The write-up of your program should tell the story of how it was developed. All elements of your programming code should be included and explained in detail. Developmental testing is important as it shows how you reacted to changes and how the software evolved.
Although there is no word limit, you should aim to be concise. Use appropriate, cropped screenshots and support these with accurate yet brief explanations of your code.