CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 6 of 6 · 3 min read

Exercises

Easy

Easy 1: Find the axes (20 minutes)

For a ride-booking system, list four axes of change.

Done when: four axes are listed, each with an example of a new variant.

Hint

Vehicle types, pricing rules, payment methods and notification channels.

Easy 2: Run both pricers (20 minutes)

Type the old method and the new Pricer. Run the four sample orders through both.

Done when: both print 900, 1650, 450 and 300.

Hint

Money amounts are whole numbers here, so no rounding appears.

Easy 3: Name the smells (20 minutes)

Read the old priceBefore method and list every smell in it with the cure.

Done when: at least three smells have a named cure.

Hint

Look at the switch, the raw numbers and the number of jobs in one method.

Medium

Medium 1: Add the festival rule (45 minutes)

Add the festival rule, then add a second rule: free shipping above 5000 (made up) as a negative adjustment. Do not edit existing classes.

Done when: both rules work and a diff shows no edits to PercentOff, BulkOff or Pricer.

Hint

A rule is a lambda or a small class.

Medium 2: Characterize first (45 minutes)

Take a method with a type switch of your own. Write ten characterization tests, then refactor it to an interface, checking after each step.

Done when: ten tests pass before and after, and you list the steps taken.

Hint

Pick ten orders that cover each case and the edges.

Medium 3: Feature envy (45 minutes)

Write a calculator that reads six getters from an Employee and computes pay. Move the logic into Employee and compare.

Done when: the pay method sits in Employee and the calculator is gone or tiny.

Hint

Count how many times the calculator calls the employee.

Hard

Hard 1: Change requests (90 minutes)

Take your parking-lot design. Answer five change requests in writing: a new vehicle type, a new fee rule, a second payment vendor, a new display, and a reserved-spot rule. For each, name the class that changes.

Done when: a table lists five requests, each with classes added and classes edited, and at most one edit per request.

Hint

If an edit touches two classes, ask which seam is missing.

Hard 2: Over-built or under-built (90 minutes)

Review a design with an interface for every class. Mark which seams earn their place and which should be removed. Then review one with none and mark where a seam is missing.

Done when: two reviews each give a list of changes with a reason from the module.

Hint

Count the classes with only one implementation and no reason to vary.

Hard 3: Refactor a real file (90 minutes)

Pick a file of about 150 lines from your own code. Write tests, then refactor it in ten or more small steps, with the tests passing after each.

Done when: a log lists each step, the tests pass at the end, and the file is clearer by your own judgement.

Hint

Commit after each green step.