Bird
0
0

Given the following pseudo-code for an anti-corruption layer translating legacy user data, what will be the output?

medium📝 Analysis Q13 of 15
Microservices - Migration from Monolith
Given the following pseudo-code for an anti-corruption layer translating legacy user data, what will be the output?
legacyUser = {"fullName": "Jane Doe", "age": 30}

function translateUser(legacy) {
  return {
    name: legacy.fullName,
    isAdult: legacy.age >= 18
  }
}

newUser = translateUser(legacyUser)
console.log(newUser)
A{"name": "Jane Doe", "isAdult": false}
B{"fullName": "Jane Doe", "isAdult": true}
C{"name": "Jane Doe", "isAdult": true}
D{"name": "Jane Doe"}
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the translation function

    The function creates a new object with 'name' from 'fullName' and 'isAdult' as true if age >= 18.
  2. Step 2: Apply the function to the legacy user

    legacyUser has fullName 'Jane Doe' and age 30, so isAdult is true.
  3. Final Answer:

    {"name": "Jane Doe", "isAdult": true} -> Option C
  4. Quick Check:

    Translate fullName and check age >= 18 = true [OK]
Quick Trick: Check property mapping and age condition carefully [OK]
Common Mistakes:
  • Using legacy property names in output
  • Incorrectly evaluating age condition
  • Missing one of the output properties

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes