An online shop uses four classes with the following roles:
CartLine construction requires only the three values listed above, and no separate construction service is required. To place construction with the class that both contains the resulting object and has its initialization data, assign responsibility for creating a new CartLine to . Enter the exact class name.
Unlock full course notes by signing up
Judging statements about controllers, coupling and cohesion
A team is reviewing the design of a shop's point-of-sale system, which has a checkout window, a RegisterController, a Sale class holding line items, and a database. Which of the following statements about how responsibilities should be assigned are sound? Select all that apply.
Classify the responsibilities of ticketing objects
A ticketing application assigns several kinds of responsibility to its objects. Match each category to the example that best illustrates it. Classify the behaviour explicitly described, rather than additional work the object might perform internally.
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.
Dependencies after an Information Expert refactor
A payroll design has five classes. Department holds a list of its Employee objects, and each Employee holds a reference to its PayGrade. In the original design, PayrollReport gets the employees from Department, reads each employee's name, hours and grade, asks PayGrade for the hourly rate, asks TaxTable for the tax rate, computes net pay and prints a line per employee.
The team refactors using Information Expert. Employee.netPay() now computes net pay using its own hours, its PayGrade and a tax rate it requests from TaxTable. Department.totalNetPay() sums its employees' net pay. PayrollReport gets the employees from Department, prints each employee's getName() and netPay(), then prints Department.totalNetPay().
Treat a dependency as directed (class X depends on class Y) and count each ordered pair of classes once, however many calls it involves. How many distinct dependencies does the refactored design contain? Answer as a whole number.