Order customer join nested loop
Review this Java method that attaches each order's customer name by matching against a list of customers.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1List<View> join(List<Order> orders, List<Customer> customers) {
2 List<View> views = new ArrayList<>();
3 for (Order o : orders) {
4 for (Customer c : customers) {
5 if (c.id() == o.customerId()) {
6 views.add(new View(o, c.name()));
7 break;
8 }
9 }
10 }
11 return views;
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.