๐ WAYPOINT LESSON
Select-transform pipelines
โญ beginnerโณ 12 min read๐ Lesson 73 of 256
Inventory, decompose, contract, assemble โ patterns glued together.
Integrated problems combine units the way the exam does. A single question may demand: an ArrayList of objects, a traversal, a String method, and a boolean contract. The strategy:
- Inventory โ list the types in play (
ArrayList<Song>,int,boolean). Each type names a toolbox from an earlier module. - Decompose โ one method per sub-task. "Find the best" and "print the report" are two methods, not one tangled loop.
- Contract per method โ one sentence: what goes in, what comes out, what's guaranteed.
- Assemble โ the driver method calls the pieces in order.
// Pieces: findBest(list), countBelow(list, cut)
public static ArrayList<String> topNames(ArrayList<Song> list, int cut) {
ArrayList<String> names = new ArrayList<String>();
for (Song s : list) {
if (s.getPlays() >= cut) {
names.add(s.getTitle());
}
}
return names;
}
Notice the pattern: select (filter by plays) + transform (extract title). Most integrated FRQs are two or three patterns glued together โ recognizing the glue is the skill.