Exercise 2: Raising the Bulk-Discount Threshold — Possible Solution ==================================================================== THE CHANGE ------------------------------ # before def apply_bulk_discount(total): return total - 5 if total > 100 else total # after def apply_bulk_discount(total): return total - 5 if total > 150 else total Only the comparison value (100 -> 150) changes, inside apply_bulk_ discount() specifically - this time the isolated function under test is a DIFFERENT one than this chapter's own platinum-tier example. VERIFYING THE OTHER TWO FUNCTIONS STAYED UNTOUCHED ------------------------------ apply_tier_discount unchanged: True apply_express_fee unchanged: True Both apply_tier_discount() and apply_express_fee() - captured via inspect.getsource() before and after the change, exactly like this chapter's own verification method - are confirmed byte-identical. Neither needed to be opened, read, or reasoned about to make this change correctly. VERIFYING THE NEW THRESHOLD BEHAVES CORRECTLY ------------------------------ total=120 (was >100, now not >150) old vs new: 115 120 total=160 (still qualifies under new threshold): 155 A total of 120 - which qualified for the bulk discount under the old threshold (giving 115) - correctly no longer qualifies under the new one (staying at 120, undiscounted). A total of 160 still qualifies (155, discount applied), confirming the new threshold works correctly in both directions, not just the direction that happens to match the example given. WHY THIS CONFIRMS THE ISOLATION PROPERTY GENERALIZES ------------------------------ This chapter's own platinum-tier example showed apply_bulk_discount and apply_express_fee staying untouched while apply_tier_discount changed. This exercise shows the REVERSE - apply_tier_discount and apply_ express_fee staying untouched while apply_bulk_discount changes. The isolation isn't a property of the platinum-tier change specifically; it's a property of the design itself - whichever single function owns a given piece of logic is the only one that ever needs to change when that specific logic changes. WHY THIS WORKS AS AN ANSWER ------------------------------ A genuinely different change (a threshold value, not a new dictionary entry) is applied to a different function than this chapter's own example, using the identical source-comparison verification technique, and the new behavior is checked in both directions (a value that lost eligibility, a value that kept it) rather than only the one case that matches the change's own intent.