Exercise 1: Does print_item_count Show the Same Feature Envy? — Possible Solution ==================================================================== THE NEW METHOD ------------------------------ class InvoicePrinter: def print_item_count(self, order): return len(order.items) RUNNING THIS CHAPTER'S OWN SELF-VS-ORDER CHECK ------------------------------ print_item_count - self. references: 0 | order. references: 1 result: 2 The identical pattern as this chapter's own print_invoice - 0 references to self's own data, 1 reference to order's data. By this chapter's own measurement, yes, this method also shows Feature Envy. IS MOVING IT TO Order AS CLEARLY JUSTIFIED? ------------------------------ Not quite as clearly, and it's worth being honest about why. This chapter's own print_invoice did real WORK with order's data - looping, multiplying, accumulating a total - genuine business logic that belongs wherever Order's own rules are defined. print_item_count does almost nothing: len(order.items) is a single built-in call with no logic of Order's own to encapsulate. Moving it to Order as order.item_count() would still be reasonable (and arguably still correct, since "how many items does this order have" is a fact about an Order, not about an InvoicePrinter) - but the SEVERITY of the smell is lower here, because there's no actual computation being duplicated or misplaced, just a trivial pass-through. WHY THIS IS A GENUINELY USEFUL DISTINCTION ------------------------------ This chapter's own reference-count check flags BOTH methods identically (0 self, 1+ order) - but the check alone doesn't distinguish "this method contains real logic that belongs elsewhere" from "this method is a one-line pass-through that happens to reference another object." Both are technically Feature Envy by the letter of the check, but the FIRST kind is the one worth actually refactoring for; the second is a much lower-priority cleanup, if it's worth doing at all. WHY THIS WORKS AS AN ANSWER ------------------------------ The new method is tested against this chapter's own exact check, confirming it technically matches the same smell signature, and the answer goes further by evaluating the SEVERITY of the smell based on how much real logic is actually involved, rather than treating every match of the mechanical check as equally worth fixing.