Implementing Computing

Aidan Delaney

aidan@ontologyengineering.org | @aidandelaney

Introduction

About Me

  • Academic for over a decade (PhD in CS involving logic).
  • Researcher in Visual Languages and Visual Reasoning.
  • Shipped code in Haskell, C, Java, Perl, Python, C++, JavaScript & others.
  • Director of an Eastbourne not-for-profit TechResort.
  • School Governor at Pashley Down and Gildridge House.
  • Involved with CAS for a while.

Takeaways

  1. Testing frameworks help.
  2. Automated testing helps assessment.

Assumptions

  • Discussing a small, but important, facet of the curriculum i.e. programming.
  • Using a text-based programming language.
  • Writing small programmes; generally \(\le\) 100 LOC.

Running example

  • OCR password example from A453
    • Write a program to test the "strength" of a password.
    • strong passwords have a capital letter and a digit.
    • medium passwords have a capital letter or a digit.
    • all passwords are between 6 and 12 characters long.

Industry-grade Development

Practices

  • Agile planning
    • backlog, user stories, sprint planning.
  • Build system
    • dependency resolution, supports "higher-level" QA practices.
  • Test framework
    • system and unit testing.
  • Source control
    • aids with transparency of development project.

Test Framework

Python Java C#
pytest JUnit NUnit
  • Provides structure for automated tests.
  • Helps in test planning.

Triangulation

Specification

  • Really helps design.
  • Cucumber is a nice specification language
  • Feature: The feature to be tested
  • Scenario: A flow of events through a feature.
  • Given, And, When, Then: Descriptions in natural language.

Example

Scenario: Short password
  Given a <short> password
  And the password is less than 6 letters long
  Then the password is unacceptable

  Examples:
    | short |
    | a     |
    | ab    |

Your Turn

It should be at least 6, and no more than 12 characters long The system must indicate that the password has failed and why...

Password strength can be assessed against simple criteria to assess its suitability; for example a password system using only upper and lower case alphabetical characters and numeric characters could assess the password strength as:

  • WEAK if only one type used, e.g. all lower case or all numeric
  • MEDIUM if two types are used
  • STRONG if all three types are used.

Steps

  • We can map each scenario into executable tests.
  • Automated systems can figure out where we've missed a step.
  • Tests can be run multiple times and are their own documentation.

Example

@given('a <short> password')
def step_input_password(short):
    return PasswordCheck.check(short)

Test First

  • Now we have a spec and a test we know "when to go home".
  • the code is done when the tests run.
  • Our code is nicely decomposed into functions with
  • user view
  • system view
  • module/unit view

Conclusion

Spec-Test-Code

  • Triangulation is key.
  • Triangulated projects make good stories.
  • This is what I'm going to do.
  • This is how it works.
  • This is what I've done.
  • Triangulation is assessment.

My Code

OCR Solution

An image of some bad code
An image of some bad code

References