Ordering messages traced from code

The Python code below runs when a Client object calls place(cart) on an OrderService. The attributes pricing, tax, payments and mailer refer to separate Pricing, TaxTable, Payments and Mailer objects, and every call except send_receipt is synchronous. Arrange the messages in the order they appear from top to bottom of the sequence diagram for this call, ignoring the final reply from OrderService to Client.


Python
class OrderService:
    def place(self, cart):
        total = self.pricing.quote(cart)
        self.payments.charge(cart.owner, total)
        self.mailer.send_receipt(cart.owner)  # queued; the caller does not wait

class Pricing:
    def quote(self, cart):
        rate = self.tax.rate(cart.region)
        return cart.subtotal * (1 + rate)
  1. 1.

    TaxTable to Pricing: reply carrying the rate

  2. 2.

    Pricing to OrderService: reply carrying the total

  3. 3.

    OrderService to Pricing: quote(cart)

  4. 4.

    OrderService to Payments: charge(cart.owner, total)

  5. 5.

    Payments to OrderService: reply from charge

  6. 6.

    Pricing to TaxTable: rate(cart.region)

  7. 7.

    OrderService to Mailer: send_receipt(cart.owner)

  8. 8.

    Client to OrderService: place(cart)

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 Sequence Diagrams Questions: