Preparing your design workspace

Loading the problem and your saved attempt…

Design Employee Username and Birth Date Rules

Model an employee that requires a username and accepts its birth date only once, with explicit error and observation contracts.

For this exercise, assume a client creates an Employee with a username. Missing, empty or whitespace-only usernames are rejected before a usable object is returned. Preserve any valid username exactly as supplied. A new employee’s birth date is unset.

The client may read the username and optional birth date and assign one birth date later.

For this exercise, assume the caller supplies an immutable valid calendar-date value; date parsing, age checks and HR eligibility rules are outside scope. The first birth-date assignment succeeds. Every later assignment attempt, including an equal value, is rejected and leaves the complete object unchanged.

Username changes and clearing/resetting the birth date are not supported. Define observable success/failure results, but choose your own class and method spellings.

Design the in-memory object boundary, interfaces and interaction trace. Implementation code is not required. Initially assume one caller at a time; persistence, authentication, payroll and user interfaces are excluded. For the follow-up, assume two threads attempt the first birth-date assignment concurrently.

Preserve exactly one winner, one rejected call and consistent reads of the assigned immutable value, and explain how you would test that race.