VCE Applied Computing: Software Development (Year 12) · Unit 3 — Programming · 16m read
Programming Fundamentals — Data Types, Data Structures and Control Structures
Unit 3 Area of Study 1 is about programming. Before algorithms and objects, you need rock-solid fundamentals: picking the right data types and structures, controlling flow, and breaking code into well-named functions.
Learning objective: Choose appropriate data types and data structures (arrays, records, associative arrays), use sequence, selection and iteration, and write modular code with functions, parameters and appropriate variable scope.
By the end of this lesson you can:
- I can choose a suitable data type and data structure for given data.
- I can write and trace code using sequence, selection and iteration.
- I can explain functions, parameters, return values and local vs global scope.
Data structures are containers. An array is a row of identical lockers numbered from 0; a record is a form with labelled boxes; an associative array is a dictionary you look up by word.
Data types and data structures
PRIMITIVE DATA TYPES: integer, floating point (real), character, string, Boolean.
DATA STRUCTURES
• ONE-DIMENSIONAL ARRAY — a fixed-size, ordered collection of elements of the SAME type, accessed by an integer index (scores[0], scores[1], …).
• TWO-DIMENSIONAL ARRAY — rows and columns, accessed by two indices (grid[row][col]).
• RECORD — a group of related FIELDS of DIFFERENT types describing one thing (a student record: name, ID, year level).
• ASSOCIATIVE ARRAY (dictionary / hash table) — stores KEY → VALUE pairs; look up a value by its key (prices["apple"]).
• Lists, queues (first in, first out) and stacks (last in, first out) are also common.
Control structures and modularity
SEQUENCE — instructions run in order.
SELECTION — IF … THEN … ELSE, and CASE/match for many options.
ITERATION — FOR loops (counted), WHILE loops (test before each pass), REPEAT … UNTIL (test after each pass, so it runs at least once).
FUNCTIONS (methods, subroutines) package a task so it can be reused and tested separately:
• PARAMETERS pass data in; a RETURN value passes a result out.
• LOCAL variables exist only inside the function; GLOBAL variables are accessible everywhere. Prefer local variables — they reduce side effects and make code easier to maintain.
INTERNAL DOCUMENTATION — meaningful names (camelCase or snake_case), comments explaining WHY, and consistent indentation improve readability and maintainability.
Worked example (Medium)
Trace the pseudocode and state the output.
FUNCTION countAbove(marks, limit)
count ← 0
FOR i ← 0 TO LENGTH(marks) − 1
IF marks[i] > limit THEN
count ← count + 1
ENDIF
ENDFOR
RETURN count
ENDFUNCTION
PRINT countAbove([72, 45, 90, 60], 60)
- Pass 1–2. i = 0: 72 > 60, count = 1. i = 1: 45 > 60 is false.
- Pass 3–4. i = 2: 90 > 60, count = 2. i = 3: 60 > 60 is false (not strictly greater).
Answer: Output: 2
Common mistakes
- Using a one-dimensional array for data of mixed types Arrays hold elements of one type. Fix: Use a record (or an array of records) when fields have different types.
- Off-by-one errors in loops Arrays usually start at index 0. Fix: A loop over n elements runs from 0 to n − 1.
- Relying on global variables Any part of the program can change them, causing hard-to-find bugs. Fix: Pass values as parameters and return results.
Practice questions
Which structure is best for looking up a product’s price using its product code?
- One-dimensional array
- Associative array
- Stack
- Queue
(1 marks)
Explain the difference between a WHILE loop and a REPEAT … UNTIL loop.
(2 marks)
Explain one benefit of using local rather than global variables.
(2 marks)
Summary
- Arrays: same type, integer index. Records: fields of different types. Associative arrays: key → value.
- Sequence, selection and iteration control the flow of every program.
- Functions use parameters and return values; prefer local variables.
- Readable code: meaningful names, comments and indentation.