55. A function accepts a date range. What contract would you define before implementing it?
EasyProgramming fundamentals
Technical
Show model answer
Clarify whether each boundary is inclusive, the accepted time zone and format, and whether an empty or reversed range is valid. Distinguish a calendar date from an instant so callers do not silently disagree.
Express those decisions as input validation and a few examples: equal endpoints, a boundary crossing and invalid input. Keep the contract small enough that another developer can predict the result without reading the implementation.
What interviewers listen for
- Explicit boundaries
- Date versus instant
- Examples before implementation