Count the maintenance impact of responsibility allocation

A parcel application has five checkout classes. Compare these two allocations of delivery-fee responsibility:


Original allocation: Each checkout class has its own quoteDelivery method. Each of these five method bodies independently contains the fee rules for Local, Regional and Express delivery. There are no shared fee helpers.


Revised allocation: Each checkout's quoteDelivery method passes the customer's chosen mode name to one shared DeliverySelector.create method, then asks the returned delivery object for its fee through the same operation. DeliverySelector.create holds an explicit mapping from each supported mode name to its delivery class, and currently maps Local, Regional and Express to LocalDelivery, RegionalDelivery and ExpressDelivery. Each of these classes implements exactly one fee method, and that method depends only on its own mode's rule. Every checkout already uses the selector, and quoteDelivery passes any mode name through without checkout-specific validation.


Consider two separate maintenance requests:

  • Request A changes only the Regional fee formula, without changing its inputs or any operation names.
  • Request B adds Overnight delivery with its own fee rule, following the same pattern as the existing modes, and the other fee rules stay as they are.

Count method bodies, not branches or lines. Include only quoteDelivery, fee and DeliverySelector.create methods; ignore constructors, tests and configuration. Report these four counts as exact integers:

  1. Existing method bodies modified for Request A in the original allocation.
  2. Existing method bodies modified for Request A in the revised allocation.
  3. Existing method bodies modified for Request B in the revised allocation.
  4. New method bodies added for Request B in the revised allocation.
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Allocating Responsibilities to Classes Questions: