Pila: a year later
Last updated
Pila has been live for a year. Four requests are waiting, one of each kind of maintenance: a bug a patient found, a provider that's closing its old service, a feature the health centre wants, and code that's getting hard to change. In this project you'll handle each one properly: a fix with a regression test that proves itself, an adapter that keeps the rest of Pila unchanged, a user story for the new feature, and a release, 1.1.0, with a changelog. And you'll keep them apart.
By the end of this lesson you can
- Fix a bug with a regression test that fails before the fix and passes after
- Adapt to a new provider with an adapter, leaving the rest of the code unchanged
- Release several kinds of change as separate, reviewable pieces, with a changelog
The four requests
A year after 1.0.1, four requests are waiting:
| Request | Kind (lesson 8.1) | In this project |
|---|---|---|
| #41: “0917 111 1111” and “09171111111” got two different numbers | Corrective | A regression test, then the fix |
| The SMS provider closes its old service in March | Adaptive | An adapter for the new provider, Tulay |
| Ate Cora wants vaccination reminders | Perfective | The user story and acceptance criteria |
reply_for is a tangle (lesson 8.3) | Preventive | Done already: your refactor from 8.3 |
Each one becomes its own branch and pull request (lesson 5.5), and all four ship together in release 1.1.0.
Fix: spaces in phone numbers
Issue #41: one patient's phone sends 0917 111 1111, with spaces, and another day 09171111111. Pila gave the same patient two numbers. Jun's line phone = phone[-10:] keeps the last ten characters, spaces included.
First, write a test in test_queue.py that shows the bug: it should fail on version 1.0. Then fix queue_rules.py so it passes. Pressing Run runs your tests on your version, then on 1.0.
Notice that Jun's +63 test still passes on your version. That's the other job of a regression suite: your fix didn't break his.
Adapt: the new SMS provider
The old provider closes in March. Lesson 6.4 passed the gateway into sms.handle(), so the rest of Pila only knows one thing about it: it has send(phone, text). That makes this change small. Write an adapter: a TulayGateway with the same send that translates to what Tulay's client wants, including writing every number as +639….
Improve: the vaccination schedule
A perfective change starts where Stage 3 did: with the user. Write Ate Cora's request as a story and criteria. You'll build this feature for real in the capstone.
- Says who it’s for (done)
- Says what they want (not yet)
- Says why (not yet)
- About vaccination (not yet)
- Uses Given / When / Then (not yet)
- At least two criteria (not yet)
- Says when the text is sent (not yet)
- Covers someone who opted out or has no phone (not yet)
Release 1.1.0
Three changes are ready, and the refactor from lesson 8.3 is merged.
- Has Added, Changed and Fixed (not yet)
- The vaccination reminders are added (not yet)
- The new SMS provider is a change (not yet)
- Fixes phone numbers with spaces (not yet)
- Links issue #41 (not yet)
Spot the trap: one pull request for everything
To save time, Marco suggests doing all four on one branch: “One pull request, one review, one release.”
What happens if…
Check what you learned
Sources
Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.
- ISO/IEC/IEEE 14764:2022, Software engineering: Software life cycle processes: Maintenance: the kinds of maintenance
- Keep a Changelog: Added, Changed, Fixed, and the other headings
- Semantic Versioning 2.0.0: why this release is 1.1.0
- Martin Fowler: Definition of Refactoring: for the preventive change