Code Review Feedback Session

Beginner English listening exercise · Dev Team Meetings

Transcript

[Senior Dev] Hey Jamie, I reviewed your pull request for the user profile feature. Overall, nice work! I have a few suggestions. [Junior Dev] Thanks, Mike. I'm ready to hear them. [Senior Dev] First, on line forty-seven, you're making a database call inside a loop. Each iteration triggers a separate query, which means if there are a hundred users, you're making a hundred database calls. [Junior Dev] Oh, I didn't think about that. What should I do instead? [Senior Dev] You should batch the query. Fetch all the users in a single query using an IN clause, then process them in memory. It's called the N+1 query problem — it's one of the most common performance issues. [Junior Dev] Got it. I'll refactor that right away. [Senior Dev] Second thing — your error handling. On line eighty-two, you're catching all exceptions with a generic catch block. If the database is down, the user just sees a blank page. [Junior Dev] Should I add specific error types? [Senior Dev] Yes. Catch specific exceptions and return appropriate error messages. For database errors, show a "service temporarily unavailable" message. For validation errors, show what the user needs to fix. [Junior Dev] Makes sense. Anything else? [Senior Dev] One more thing. Your variable names are a bit unclear. "temp" and "data2" don't tell me what they represent. Use descriptive names like "userProfile" and "formattedAddress." It makes the code self-documenting. [Junior Dev] Great feedback. I'll push the updates by end of day.

Comprehension questions

  1. What is the N+1 query problem?
  2. Why are descriptive variable names important?
  3. What feature was Jamie working on?
  4. What is a suggested improvement on line forty-seven?
  5. What type of error handling should Jamie use according to the Senior Dev?

More Dev Team Meetings exercises