Skip to content
A quiz or lab to challenge a student's ability to refactor for both efficacy and inclusivity.
Swift Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
java
swift
.gitignore
README.md

README.md

Salutations Quiz

This quiz (which could easily be morphed into a short lab) seeks to have the student refactor code to improve both its efficacy as code (it only needs to be one class) and its inclusivity (e.g., not everyone who may one day be a wife will have a husband).

Below is the prompt given to the students on the handout. I also gave them access to the code files (and I made similar Java files for use in an AP CS A Classroom).

Suppose that you received the below Swift code from a teammate on a project. There are a few problems with it. First of all, it certainly could be more inclusive. It also doesn’t really need to be two different classes. These are not necessarily the only issues, however, there are no bugs in the code. It’s not “wrong”, it’s “bad”. In an Xcode Playground, write and test a class which would better solve the same problem of encoding data about people getting married and their salutation(s). This means you have some choices!

You can’t perform that action at this time.