Name the pain, then choose the pattern, for Mbak Tyas's school bus app. Sometimes the cure is none. 12 levels, right in the browser.
What the levels ask
13 July, the first day of school. For a year Ms. Tyas has run Jemputan, a small app for the school bus that leaves from Mundu Lane. The morning news in pagi.js was written by Mr. Piksel with EventTarget: anyone who signs up through dengarPagi(fn) hears when the bus leaves. The afternoon news in sore.js is still one send line per parent. Ms. Tyas wants sore.js to use the same pattern, because two requests are already waiting. Pick what goes in sore.js.
20 July. Three parts of Jemputan hurt in the same way. Trip types are written in two functions (tarifJenis and jamJenis), the school's attendance is called directly in two places in the school's own shape, and the news to parents is written again in berangkat() and sampai(). Three requests arrive, one for each part. For each part, pick the family of patterns that cures it.
10 August. absenPagi.js and absenSore.js each open their own connection to the school's server. That server accepts only two connections at a time, and Mrs. Ratna will ask for the afternoon lesson's attendance too. Mr. Piksel suggests a Singleton like the one in the Java book. Pick how each file gets its connection.
24 August. Mr. Piksel wants to wrap rupiah() in an interface, a factory and a class, so it is ready for other formats. The function is five lines and has never changed. Two requests arrive this month: the lesson bill and the yearly total. Name the pain first, then pick the shape of rupiah.js.
7 September. For the first time there is a bill that is not monthly: a trip to the district museum, just once. Mr. Piksel suggests a Strategy now, because other kinds will surely come later. Name the pain first, then pick the shape of tagihan.js before the trip bill is added.
5 October. For two months the zone fare if was copied into papan.js and kwitansi.js to save time. Now Mr. Tono asks for the Rice Field Lor zone, and diesel is going up. Name the pain in one sentence, then pick its cure.
2 November. jemput(), susulan() and jemputLes() in naik.js run the same steps: record attendance, write the board, send a WA to the parent. The neighbourhood head asks for each child to be written in the neighbourhood book too, and then Mrs. Ratna asks for the school to be told as well. Name the pain, then pick its cure.
7 December. Last year Mr. Piksel wrote NomorTagihan as a Singleton and the zone fares as a Strategy, one class per zone. This month the bill number gets the month in it, and then the Rice Field Lor zone arrives. Pick the shape of both parts.
8 February. Three parts of Jemputan look alike: each is an object full of functions. The pick-up news goes through the channel a parent chose. The flood news must reach everyone signed up. What happens when a child is picked up or cancelled depends on that child's status. Pick the intent for each part. This month's requests do not change the code at all: only the right intent handles them.
8 March. Two new needs. Mr. Harun brings the district bus's passenger data in its own shape. In April and May the bus's air conditioning is on, and the bill goes up by Rp10,000 but is still one number. kirimSemua(daftar, hitung) and tagihan(anak) may not be changed. Pick the intent for each need. The requests are only data and new months, with no code edits.
5 April. The morning, midday and lesson trips each write their own object with the same fields. Mrs. Ratna asks for every trip to record its chaperone. Mr. Piksel has already prepared a factory that uses a Builder that uses a Singleton, to be complete. Name the pain, then pick its cure.
19 June, report card day. Ms. Tyas plays this year's requests again: the Rice Field Lor zone, the school being told too, the lesson attendance, the diesel increase, the neighbourhood group, the Krajan Atas zone. Pick the shape of three parts of Jemputan: the zone fares, the news to parents, and the connection to the school's server.