Fundamentals · Easy · Free
How do naming, parameters, and return types make APIs readable?
FresherFundamentalsOOP & Language Fundamentals
Readable APIs
- Names: verbs for actions (
createOrder), nouns for data (Order). - Parameters: few, ordered general → specific; use objects for many options.
- Returns: Optional/Result instead of null; throw for exceptional cases.
- Consistency: same terms across REST and service layer.
Good API reads like prose: orderService.cancel(orderId, reason).
Mention idempotency in method docs for payment APIs.