Zum Inhalt springen

English:Computational abstraction and state modelling - Computing Year 7

Aus MOOCsWiki Staging
aiMOOC-Siegel aiMOOC

Computational abstraction and state modelling - Computing Year 7

QR-Code



Introduction

A real library used as context for a fictional one-item model
The photograph illustrates the setting only. The states, events, transition table, code and test traces below are original educational models, not records of this library or real learners.

Select the information a question needs, build a complete state model, trace accepted and rejected events, and test whether the abstraction is sufficient. Year 7 allocation is editorial within England’s KS3 Computing pathway; an optional short Python implementation extends the paper model.


Select the detail a computational model needs

An abstraction keeps the detail needed for a particular question. Imagine a library deciding whether one fictional item is available to borrow. A complete photograph of every shelf is useful for some purposes, but it does not directly tell a program which borrowing actions are currently permitted. A model can instead represent an item using a small set of states and rules.

For this course the question is: what should happen when a reserve, borrow, collect, cancel or return event arrives for one item? We deliberately omit shelf colour, cover artwork and the temperature of the room. We also omit real borrower identities, overdue fines, multiple-copy handling and reservation queues. These omissions simplify the task, but they limit what the model can answer. Abstraction is purposeful selection, not randomly deleting information or claiming the simplified model is a complete library system.

Shelves of books in a real library
Roc0ast3r’s unchanged Kent Library photograph supplies real-world context. This is a library in Washington, USA, not a photograph of a particular English school or the fictional system below. The picture does not reveal the current loan status of any book; those statuses are represented by the original model.

A state records a current condition relevant to future behaviour. An event is something received or occurring; a transition is the rule that uses the current state and event to determine what follows. An output can report acceptance or rejection. State is not the same as an instruction, an event history or a diagram arrow, even though these ideas can be shown together.

Our item has exactly one of three mutually exclusive states: AVAILABLE, HELD or ON_LOAN. AVAILABLE means no reservation hold or current loan is represented; HELD means an item is held for collection in this simplified model; ON_LOAN means it is currently borrowed. These are definitions for the model, not universal names every real library must use. Start in AVAILABLE unless a test explicitly supplies a different initial state.

Choose relevant variables from the question. If the question changes to “Who may collect this item?”, a single HELD label is insufficient: a real design needs suitable identity/permission information and additional rules. If the question becomes “Which copy is at which branch?”, one-item state is insufficient. A model can be useful for permitted-event reasoning while inadequate for identity, scheduling or a real operational service.

States should distinguish situations with different future behaviour. In a fictional lift example, using only MOVING without remembering the requested destination cannot distinguish travel requested to floor one from travel requested to floor two. Adding a target-floor variable or suitable distinct states can repair that information loss. This is a reasoning model, not operating code or a safety assessment for a physical lift.

Identify how a task determines which details matter, then list what the original one-item library model keeps and omits. The video introduces abstraction; the complete state rules and traces in this course provide the separate state-modelling extension and written offline alternative. Original: CodeAI, Unplugged - Abstraction. The written explanations and native tasks work without sound or the external player.


Define states, events and complete transition rules

A state model needs explicit rules for both permitted and invalid events. The following original transition table defines every permitted change in our one-item library model. Event names are exact lower-case strings. A rule applies only when both its current state and event match; finding the event name somewhere in the table is not enough.

Current state Event Next state
AVAILABLE reserve HELD
AVAILABLE borrow ON_LOAN
HELD collect ON_LOAN
HELD cancel AVAILABLE
ON_LOAN return AVAILABLE

Any other event in a recognised state is rejected and leaves the state unchanged. This includes a collect event in AVAILABLE, a borrow event in HELD and a reserve event in ON_LOAN. An unknown event name is rejected too. In an implementation, an unrecognised current state is a separate modelling/data error to detect; do not silently treat it as AVAILABLE. The paper model assumes one event is processed at a time.

Represent each state with a labelled node and each permitted transition with an arrow labelled by its event. Mark the initial state separately. Draw two arrows leaving AVAILABLE, one for reserve and one for borrow; two leaving HELD, for collect and cancel; and one leaving ON_LOAN, for return. Do not label an arrow only “next” when the event is what determines which transition applies.

You may show rejection rules in a separate note or explicit self-return arrows with rejection outputs. Returning the same state does not mean an action was accepted. For example HELD plus borrow remains HELD and reports rejection: the unchanged state and the response are two distinct parts of the result. A future renewal feature could legitimately leave a state unchanged while being accepted, but it is not part of this model.

A flowchart showing temperature input, conversion and output
Dave Braunschweig’s unchanged Flowgorithm example is a procedure flowchart, not our library state diagram. Its boxes show steps in a temperature-conversion procedure. In a state diagram, nodes represent persistent conditions and labelled arrows events; do not rename each procedure box as a library state.

Trace a sequence one event at a time, recording the state before, the event, the response and the state after. The next row begins with the previous row’s resulting state. Here is an original nine-event trace from AVAILABLE; rejected events are retained rather than removed from the history.

Step Event State before State after Response
1 reserve AVAILABLE HELD Accepted
2 borrow HELD HELD Rejected
3 collect HELD ON_LOAN Accepted
4 return ON_LOAN AVAILABLE Accepted
5 collect AVAILABLE AVAILABLE Rejected
6 borrow AVAILABLE ON_LOAN Accepted
7 reserve ON_LOAN ON_LOAN Rejected
8 return ON_LOAN AVAILABLE Accepted
9 cancel AVAILABLE AVAILABLE Rejected

Five events are accepted and four rejected; the final state is AVAILABLE. The first rejected borrow does not cancel the hold or jump to a loan, and the later rejected collect does not conjure a reservation. If an incorrect trace assumes an event always has the same effect, point to the first row where its current-state condition was ignored.

A deterministic model gives one defined result for a recognised state and a given event. Two competing rules for the same state/event pair would make that description ambiguous unless a priority or additional condition is supplied. Completeness also matters: our stated rejection rule covers combinations not listed as permitted, instead of leaving them to guesswork. Keep the rule table and diagram consistent when adding or changing a feature.



Test the model and evaluate its assumptions

Evaluate a model by testing requirements and explaining its limits. For the three recognised states and five named events there are fifteen possible state/event combinations. Only the five table entries are accepted; ten other named combinations must be rejected without changing the current state. This complete small test space is more informative than trying only the happy path reserve, collect, return.

Useful invariants describe conditions that must remain true under the model rules. The item has exactly one recognised state after any event processed from a recognised state. An accepted borrow event begins in AVAILABLE, not HELD or ON_LOAN. A rejected event retains the previous state. These are properties of our defined model, not evidence that a real library has no simultaneous requests, network failures or permission problems.

Test boundary and invalid situations deliberately. Try collect before reserve, reserve while on loan, return while already available and an unknown event such as renew. In this model each is rejected in the relevant stated situation. Record the input state as well as the event; testing the word return without its starting state leaves the expected result unclear. Tests should include expected outcomes chosen from the specification, not merely whatever a program happens to produce.

A photograph of Python source code on a display
Weal2019’s unchanged photograph provides textual-programming context. Its visible matrix and graph code is not an implementation of our item-state model and need not be copied or run. The short original optional function below is the actual implementation to compare with our transition table.

Optional Python extension. The core state-table and diagram tasks do not require prior Python knowledge. This pure function uses strings and a small dictionary to represent the same model; it has no network, account, file or real-device effects. Call it with a recognised state string and an event-name string. The returned pair is the next state and an acceptance flag; the function does not secretly update the caller’s variable.

STATES = {"AVAILABLE", "HELD", "ON_LOAN"}
NEXT = {
    ("AVAILABLE", "reserve"): "HELD",
    ("AVAILABLE", "borrow"): "ON_LOAN",
    ("HELD", "collect"): "ON_LOAN",
    ("HELD", "cancel"): "AVAILABLE",
    ("ON_LOAN", "return"): "AVAILABLE",
}

def change(state, event):
    if state not in STATES:
        raise ValueError("Unknown model state")
    target = NEXT.get((state, event))
    if target is None:
        return state, False
    return target, True

For example change with AVAILABLE and reserve returns HELD with True. Calling it with HELD and borrow returns HELD with False. The caller must use the returned next state for the following event. If it repeatedly sends the original AVAILABLE value, it is not tracing the evolving model even though the individual function calls run. An unknown current state raises the stated error rather than hiding a broken model record.

The implementation is optional evidence, not the definition of correct behaviour. Compare every table entry and rejection case with the independent specification. The course’s code was actually checked against all fifteen named combinations, additional unknown events and the complete nine-event trace. That establishes these tested properties for this small educational function, not production readiness, account authorisation or reliable concurrent library operation.

Now change the requirements. A queue of people waiting while an item is ON_LOAN cannot be represented by the current state label alone. Adding a waiting list may require a new variable and a revised return rule that moves the item to HELD rather than AVAILABLE when a reservation remains. A model change must revise the table, diagram, trace expectations and tests together. Do not keep old test answers while quietly changing the meaning of a state.

For a transfer project, model a fictional quiz with NOT_STARTED, ANSWERING, FEEDBACK and FINISHED states. Name start, submit, continue and finish events and specify which are permitted from each state. Decide how invalid events are handled and what information about question position must be retained. This is a new paper model, not a modification of MOOCwiki’s actual quiz or learning-point rules.

Evaluate your own result using four questions: does it answer the chosen question, retain the information needed for future behaviour, define what happens for invalid inputs, and explain important omissions? Submit a state diagram, a transition table, one successful and one rejected trace, and a short limitation/improvement statement. A compact model is valuable when its assumptions are visible, not when it pretends to represent everything.



Interactive Tasks


Quiz: Test Your Knowledge

What makes an abstraction useful? (It retains details needed for a stated question and explains important omissions) (!It copies every detail of reality regardless of the question) (!It removes information randomly until the model is short) (!It guarantees real-world reliability because a diagram looks tidy)



Which item is a state in the original library model? (HELD, describing a current condition) (!reserve, naming an incoming event) (!An arrow with no label) (!A complete history of all users and fines)



What happens for AVAILABLE plus reserve? (The model moves to HELD and accepts the event) (!It moves directly to ON_LOAN regardless of the table) (!It stays AVAILABLE because every event is rejected) (!It proves who is authorised to collect in a real library)



What happens for HELD plus borrow? (It remains HELD and reports rejection) (!It becomes ON_LOAN because borrow always succeeds) (!It becomes AVAILABLE by cancelling the hold silently) (!It creates a new reservation queue automatically)



How many named state/event combinations exist here? (Fifteen from three recognised states and five named events) (!Five because there are five accepted entries only) (!Nine because one trace contains nine steps) (!An unlimited number of current states in this defined model)



What distinguishes a procedure flowchart from the state diagram here? (Procedure boxes represent steps while state nodes represent persistent conditions) (!Every procedure box is automatically a library state) (!A state arrow never needs an event label) (!The two diagram types must contain identical nodes)



What follows from the original nine-event trace? (Five accepted, four rejected and final state AVAILABLE) (!All nine accepted because the inputs have recognised names) (!Final state HELD because rejected events erase successful returns) (!The original starting state must be reused for every row)



Why is MOVING alone inadequate for the stated lift destination question? (It omits which destination must distinguish future arrival behaviour) (!It stores every possible destination automatically) (!It proves motor safety without any other information) (!No real-world process can ever be modelled)



What must the optional Python caller do for a sequence? (Use the returned next state as the state for the following event) (!Assume the function secretly updates every caller variable) (!Ignore the acceptance flag and treat every call as a successful loan) (!Copy and run the unrelated matrix code from the photograph)



What is needed when adding a reservation queue? (Revise relevant data, rules, diagrams and expected tests together) (!Keep every original return rule even when requirements change) (!Treat a HELD label alone as a complete identity and permission system) (!Discard all invalid-event cases so the new model looks simpler)





Memory Game

Abstraction Purposeful selection of details needed to answer a question
State A current condition relevant to future behaviour
Event An incoming occurrence considered by the model
Transition A rule mapping a current state and event to a result
Initial state The stated condition before the first event
Invariant A property required to remain true under the defined rules





Drag and Drop

The item is AVAILABLE and reserve arrives Move to HELD and accept
The item is HELD and collect arrives Move to ON_LOAN and accept
The item is ON_LOAN and return arrives Move to AVAILABLE and accept
The item is HELD and borrow arrives Remain HELD and reject
The question changes to who may collect Add suitable information and rules rather than trusting a state label alone





Crossword Puzzle

ABSTRACTION What selects relevant details for a purpose?
STATE What records a current condition in this model?
EVENT What may trigger a permitted change?
TRANSITION What connects a state and event to the next result?
INITIAL What describes the state before a trace begins?
INVARIANT What model property must remain true across defined processing?





LearningApps

Optional extra practice. Choose an appropriate activity with your teacher. If the external collection is unavailable, use the native activities and independent tasks in this course.


Cloze Text

Complete the explanation.
A computational model serves a stated

. A state records a current

. A transition depends on the state and the

. The initial item state is

. A reserve event can move it to

. A rejected event leaves the state

. Each trace row begins with the previous result

. The fifteen named combinations include ten

cases. An abstraction should explain its

. New requirements can require a model

.



Open Tasks


Easy

  1. Keep and omit: State the original question, three relevant features and two deliberately omitted details.
  2. Name the parts: Distinguish a state, event, transition, output and initial state using the original table.
  3. Draw the model: Show all three states and five labelled permitted arrows, with the rejection rule visible.
  4. Trace a happy path: Trace reserve, collect and return from the stated initial state.


Standard

  1. Trace rejected events: Reproduce the complete nine-event trace without dropping rejected inputs.
  2. Complete the test space: List the fifteen named pairs and distinguish the five accepted from ten rejected cases.
  3. Compare diagrams: Explain why the temperature-conversion flowchart is not the item-state diagram.
  4. Repair lost information: Explain what target information the fictional MOVING-only lift model fails to retain.


Advanced

  1. Audit the optional implementation: Check the short function against the table, invalid events and the need for caller state updates.
  2. Extend a requirement: Add a waiting reservation queue and identify which data, rules and tests must change.
  3. Design a quiz model: Create states, event rules, invalid-event handling and a retained question-position variable.
  4. Evaluate model limits: Explain why this one-item abstraction cannot certify real identities, concurrency or an operational service.



Learning Check

  1. Purpose and relevant detail: Choose information using the question rather than appearance.
  2. Complete transition rules: Use current state and event together.
  3. Nine-event trace: Carry each result into the following row.
  4. Diagram meaning and remembered information: Distinguish state from a procedure step and from insufficient memory.
  5. Implementation and checks: Compare code results with independent specified expectations.
  6. Revision and transfer: Change assumptions, not just a diagram label.


Worked checks and assessment guidance

  1. The model answers which listed item events are permitted from its current condition. State labels and transition rules matter; cover artwork and shelf colour do not for this question. Real borrower identity, queues, multiple copies and fines are deliberately omitted, so the abstraction is not a complete library system or permission check. A changed question may make an omitted feature essential.
  2. AVAILABLE plus reserve becomes HELD and plus borrow becomes ON_LOAN. HELD plus collect becomes ON_LOAN and plus cancel becomes AVAILABLE. ON_LOAN plus return becomes AVAILABLE. These five named pairs are accepted; the ten other recognised-state/named-event combinations are rejected and retain state. Unknown event strings are rejected too; an unrecognised state is detected separately rather than reset silently.
  3. From AVAILABLE, reserve gives HELD accepted; borrow retains HELD rejected; collect gives ON_LOAN accepted; return gives AVAILABLE accepted; collect retains AVAILABLE rejected; borrow gives ON_LOAN accepted; reserve retains ON_LOAN rejected; return gives AVAILABLE accepted; cancel retains AVAILABLE rejected. There are five accepted and four rejected events, ending AVAILABLE. A rejection does not erase the current condition or create a new loan.
  4. The supplied flowchart shows input, conversion and output steps, whereas a state diagram node describes a condition persisting between events. A MOVING-only lift model loses the requested destination if different requests lead to the same unqualified state. A target variable or suitable distinct states can retain it. This reasoning does not supply physical lift control or safety certification.
  5. The optional function implements exactly the five table entries and returns unchanged state with False for other event strings. It raises the named error for an unknown current-state string. The caller must use the returned next state. All fifteen recognised state/event pairs, additional invalid events and the complete nine-event trace were actually tested. These checks verify this small educational model, not account authorisation, networking, concurrent requests or production operation.
  6. A real reservation queue needs extra data and can change the return rule: an item may become HELD for the next reservation rather than AVAILABLE. Revise the table, diagram, traces and test expectations consistently. A separate quiz model needs state/event rules plus enough question-position information. Submit explicit assumptions and invalid-event behaviour; a small model is valuable when it answers its stated question without pretending to cover every real detail.


Learning evidence

Submit a purpose statement, three-state diagram, complete transition/rejection rules, successful and rejected traces, a test-space table and a justified limitation or extension. Optional implementation evidence must match the specified model; use only fictional item data.


OER and Wikipedia

Original one-item library state model, all rules, traces, Python function, test expectations and transfer tasks. No real library account, borrower record, physical controller or MOOCwiki quiz was changed.

DfE Computing programme of study, KS3 design/use/evaluation of computational abstractions; Year 7 allocation is editorial. The original Code.org video supports abstraction with a separate authored state-model extension. Source checked 13 November 2026. All three Commons originals retain their real credits and licences and were visually inspected; the source-code photograph is not the original optional implementation.

International books at Kent Library.jpg, Roc0ast3r, CC0. Unchanged original; caption and learning activities are original.

Flowgorithm Input Process Output.svg, Dave Braunschweig, CC BY-SA 4.0. Unchanged original; caption and learning activities are original.

Python Code.jpg, Weal2019, CC0. Unchanged original; caption and learning activities are original.


Linked learning areas


aiMOOC Projects



Schulfach+




aiMOOCs



aiMOOC Projekte









MOOCwiki · Deutsch

Nach dem Lernen ist vor dem Lernen

Entdecke direkt den nächsten Lernkurs. Weitere Inhalte erscheinen, wenn Du weiter nach unten scrollst.

Zur MOOCwiki-Hauptseite

Mediathek

Suche verfeinern

Dein Lernplan bestimmt, was oben steht. Alle anderen Inhalte bleiben erreichbar. Seitenaufrufe beeinflussen die Auswahl nicht.

Inhalte werden geladen ...

Mediathek wird aus dem Wiki geladen ...