A larger program often splits responsibilities across source files. In this replay, one execution starts in the order application, jumps into the price service, then returns with the computed result.

request A request is a small data object passed from a client-side part of a program to a server-side part.
response A response is the result returned by the server-side part.

One Execution Across Files

quantity
OrderApp.java
Replay: real traced execution (multi-file project)
public class OrderApp {
    public static void main(String[] args) {
        int quantity = 2;
        int unitPrice = 15;
        int total = PriceService.total(unitPrice, quantity);
        System.out.println("total=" + total);
    }
}
public class OrderApp {
    public static void main(String[] args) {
        int quantity = 1;
        int unitPrice = 15;
        int total = PriceService.total(unitPrice, quantity);
        System.out.println("total=" + total);
    }
}
public class OrderApp {
    public static void main(String[] args) {
        int quantity = 3;
        int unitPrice = 15;
        int total = PriceService.total(unitPrice, quantity);
        System.out.println("total=" + total);
    }
}
  1. quantity ← 2, unitPrice ← 15

    1public class OrderApp {2    public static void main(String[] args) {3        int quantity→ 2 = 2;  //@quantity=1, 34        int unitPrice→ 15 = 15;5        int total = PriceService.total(unitPrice15, quantity2);6        System.out.println("total=" + total);
  2. subtotal ← 30, shipping ← 0

    1public class OrderApp {2    public static void main(String[] args) {3        int quantity→ 30 = 2;  //@quantity=1, 34        int unitPrice = 15;5        int total = PriceService.total(unitPrice, quantity);6        System.out.println("total=" + total);
    values this step0shipping15unitPrice2quantity
  3. total ← 30

    4    int unitPrice = 15;5    int total→ 30 = PriceService.total(unitPrice15, quantity2);6    System.out.println("total=" + total30);7}
    outputtotal=30