The answersDownload the PDF
Worksheet

A14.6 Software engineering tools and version control

Software development, law and ethics · A level · OCR H446 1.2.3, AQA 7517 4.13.1.3, Eduqas A500QS 1.7 · about 40 min

BugBotLab
NameClassDate

What this lesson is about

IDEs, CASE tools, documentation, and version control: commits, branches, merges and finding the commit that broke the robot.

Questions 6 marks in all

  1. [1 mark]Two developers need to work on different features of the robot's code at the same time. Which version control feature supports this?

    1. ABranches, later merged into the main line
    2. BSyntax highlighting
    3. CA watch window
    4. DA compiler
  2. [1 mark]Which IDE feature stops the program at a chosen line so its variables can be inspected?

    1. AA breakpoint
    2. BAuto-complete
    3. CSyntax highlighting
    4. DA merge
  3. [1 mark]What is a merge conflict?

    1. ATwo branches changed the same lines differently, so a person must decide what to keep
    2. BTwo files have the same name
    3. CA commit has no message
    4. DThe program fails a test after a merge
  4. [1 mark]Which of these belong in technical documentation rather than user documentation?

    Tick every answer that is true.

    1. AThe purpose and parameters of each subroutine
    2. BThe data structures used
    3. CHow to send a parcel with the robot
    4. DWhat each error message on the screen means
  5. [1 mark]What does this count of changed lines print?

    old = "a\nb\nc".splitlines()
    new = "a\nc\nd\nd".splitlines()
    added = sum(max(0, new.count(x) - old.count(x)) for x in set(new))
    removed = sum(max(0, old.count(x) - new.count(x)) for x in set(old))
    print(f"+{added} -{removed}")
  6. [1 mark]What does CASE stand for in CASE tools?

The task: the commit log

versions is a list of commits in order. Each is a tuple (message, text): message is a string, and text is the whole program at that commit, as one string with lines separated by \n. Write a function changes(old, new) that takes two such texts and returns a tuple (added, removed). A line counts by its exact text, including its indentation. If a line appears more times in new than in old, the extra appearances count as added; if it appears more times in old than in new, the extra appearances count as removed. Compare each commit with the one before it; the first commit is compared with the empty string "". For each commit print commit <n>: <message> (+<added> -<removed>), numbering from 1. Then find the first commit whose text contains the string in BUG, and print bug introduced in commit <n>: <message>. The robot stays still.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

versions = [
    ("first drive", "from bugbot import *\nconnect()\nforward(50, distance=20)"),
    ("stop at the wall", "from bugbot import *\nconnect()\nwhile distance() > 20:\n    forward(50, distance=5)"),
    ("faster approach", "from bugbot import *\nconnect()\nwhile distance() > 20:\n    forward(100, distance=50)\nled(\"green\")"),
    ("beep when parked", "from bugbot import *\nconnect()\nwhile distance() > 20:\n    forward(100, distance=50)\nled(\"green\")\ntone(880, 0.3)"),
]
BUG = "forward(100, distance=50)"

def changes(old, new):
    pass

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/a14-6-tools-and-version-control/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Two students edit the same line of approach() on different branches. Describe what happens when the second branch is merged, and how it is resolved.
  2. Write bisect(versions, bad) that finds the first version containing bad by testing the middle version each time, and count how many versions it looks at.
  3. List three things a user guide for the delivery robot must contain, and three things its technical documentation must contain.