← Bloomberg Interview Insights
I started with the happy path and it went fine, but then they asked about consecutive packets and I fumbled a bit.
Start by clarifying requirements and defining the public API with clear method signatures, then walk through the internal state machine and error handling. Emphasize edge cases like consecutive packets, oversized input, and thread-safety, and justify design choices with trade-offs.
Pro tip: Explicitly discuss how you would test the assembler, including unit tests for boundary conditions and concurrency tests, to demonstrate production readiness and attention to detail.
Ask about expected fragment sizes, maximum payload size, threading model, and error reporting preferences to scope the design.
Specify class name, constructor, and methods (e.g., feed(byte[] fragment) returning Optional<byte[]> or throwing exceptions) with clear contracts.
Explain fields (buffer, expectedSize, bytesReceived), how state transitions from expecting header to accumulating payload, and reset behavior after emission.
Detail validation for header (e.g., size > 0, within max limit), behavior for oversized fragments, and how to signal errors (exceptions vs. error states).
Discuss thread-safety (synchronization or thread confinement) and outline test cases for normal flow, errors, and concurrent access.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.