Maintenance and the end of life · lesson 7 of 7
Ideas in this lesson
ACorrectivea fix, with a regression test (lesson 6.9)
BAdaptivean adapter for the new SMS provider
CPerfectivethe vaccination schedule, as a story
D1.1.0the release, and its changelog

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:

The four requests
RequestKind (lesson 8.1)In this project
#41: “0917 111 1111” and “09171111111” got two different numbersCorrectiveA regression test, then the fix
The SMS provider closes its old service in MarchAdaptiveAn adapter for the new provider, Tulay
Ate Cora wants vaccination remindersPerfectiveThe user story and acceptance criteria
reply_for is a tangle (lesson 8.3)PreventiveDone 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.

Step 2 code
Edit the code, then run it again

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….

Step 3 code
Edit the code, then run it again
Why did this change touch only gateways.py?

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.

Vaccination remindersKept in this browser only
  • 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)
Write each part until its checks pass.

Release 1.1.0

Three changes are ready, and the refactor from lesson 8.3 is merged.

What should the version number be?
ChangelogKept in this browser only
  • 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)
Write each part until its checks pass.

Spot the trap: one pull request for everything

Spot the trapMarco

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

How do you know a regression test really tests the bug?
What does an adapter do?
Why doesn’t the refactor appear in the changelog?

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.

All sources for Simple Software Development