VCE Applied Computing: Software Development
46 notatek do nauki dla VCAA VCE Computer Science, utworzonych przez cookie, w 4 sekcjach zgodnych z tematami kursu.
Notes for VCE Applied Computing: Software Development (VCAA, Units 3 and 4), in four folders that follow the study design in order: programming, analysis and design, development and evaluation, and secure software development practices. Code examples are in Python and pseudocode, and each note covers one topic. Delete any folder you have already finished once the notes are yours.
Co zawiera
Pierwsza notatka
Programming / Data types
A data type says what kind of value a variable holds and so which operations make sense on it. A program stores a person's name, their age, the price of an item, whether they are logged in and the day they enrolled in quite different ways, and choosing the right type for each one is the first design decision made about any piece of data. Most languages check types (or convert between them) whenever a value is assigned or used in an expression, which is why a wrong choice shows up later as a wrong answer or a crash.
The types a program commonly needs are text, numeric, date/time and Boolean.
Text
A character is a single symbol: a letter, digit, punctuation mark or space. A string is a sequence of characters, such as a name, an address or a postcode. Strings are the right type for anything that is identified by its symbols rather than calculated with, and that includes values made of digits.
A phone number, a postcode or a student ID should be stored as a string. Nobody adds two phone numbers together, and a number type would drop the leading zero from 0412 345 678, because an integer has no way of recording a leading zero. A string also keeps the spaces and the plus sign in +61 3 9123 4567.
Common string operations are concatenation (joining two strings), finding the length, extracting part of a string (a substring), changing case and comparing two strings.
first = "Mia"
last = "Chen"
full_name = first + " " + last # "Mia Chen"
print(len(full_name)) # 8
print(full_name[0:3]) # "Mia"Comparing strings is normally done character by character using the underlying character codes, so "apple" comes before "banana", and in most languages an upper-case letter sorts before any lower-case letter unless the comparison is told to ignore case.
Numeric types
Integer
An integer holds a whole number, positive, negative or zero, with no fractional part. It suits counts (the number of items in a cart), ages in years, array positions and anything that cannot be part-way between two values. Integer arithmetic is exact, so 7+5 is always exactly 12. In many languages dividing one integer by another discards the remainder, so 7/2 gives 3 in a language with integer division, while others return 3.5. A program should be written with the behaviour of its own language in mind, and the remainder (modulus) operator is used to keep what integer division throws away.
An integer stored in a fixed number of bits has a largest and smallest value. Going beyond it is an overflow error, covered with the other run-time errors.
Floating point
A floating point number (often called a float, real or double) holds a number that can have a fractional part, such as a price of 4.95, a temperature of 36.6 or a measurement of 1.82 metres. Floating point values are stored in binary, and many decimal fractions cannot be represented exactly in binary, so a result can differ very slightly from what the arithmetic suggests. In most languages 0.1+0.2 does not equal exactly 0.3. This is why programs avoid testing two floating point values for equality and compare them to within a small tolerance instead, and why money is often held as a whole number of cents rather than as a float.
| Value | Suitable type | Reason |
|---|---|---|
| Number of tickets booked | Integer | Whole items only |
| Weight of a parcel in kilograms | Floating point | Can be fractional |
| Price in dollars and cents | Floating point, or integer cents | Fractional, but exactness matters |
| Year of birth | Integer | Whole number, not used as text |
| Student ID 00482 | String | Leading zeros, never calculated with |
Date/time
A date/time type stores a calendar date, a time of day or both. It is better than storing a date as text because the language then knows how calendars work. It can subtract one date from another to give a number of days, add 30 days to a due date and get the month right, sort dates in chronological order (text dates like "9/12/2025" sort wrongly), and check that a date is real (there is no 31 June).
from datetime import date
enrolled = date(2025, 3, 10)
today = date(2025, 9, 1)
days_enrolled = (today - enrolled).days # 175A date/time value is usually shown in a chosen format, such as DD/MM/YYYY, but the stored value is independent of how it is displayed. Keeping those two apart is what lets one program show Australian and American users the same date in the layout each expects.
Boolean
A Boolean holds one of two values, true or false. It records the outcome of a condition (is the password correct, is the stock level below the reorder point) or a yes/no property (has the user accepted the terms). A Boolean is what selection and repetition statements test, and it is the result of every comparison such as age≥18.
is_adult = age >= 18
has_stock = quantity > 0
can_buy = is_adult and has_stockNaming a Boolean as a statement that is either true or false (is_adult, has_stock) makes the conditions that use it read almost as plain English.
Choosing a type
The choice follows from what will be done with the data, rather than what it looks like.
- If it will be calculated with, use a numeric type, an integer when only whole values make sense and floating point when fractions are needed.
- If it is an identifier, code or label, even one made of digits, use a string.
- If dates need comparing, sorting or adding to, use date/time.
- If it is one of exactly two states, use a Boolean.
A type also affects how much memory a value takes and how fast it can be processed, and it gives the first level of validation for free: a field declared as an integer cannot accept the text "twelve" without an error. That automatic rejection is the basis of type checking, which is covered with the other validation techniques.
Design documents record the choice in a data dictionary, where each data item is listed with its type, so the programmer can build exactly what was designed.
I jeszcze 45: otwórz dowolne z nich z powyższej listy.
Opinie
Nie ma jeszcze pisemnych opinii. Dodaj te notatki do swoich, a możesz być pierwszą osobą, która doda opinię.